/* PIKA - Photo and Image Kooker Application
 * a rebranding of The GNU Image Manipulation Program (created with heckimp)
 * A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
 *
 * Original copyright, applying to most contents (license remains unchanged): 
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

/* NOTE: This file is auto-generated by pdbgen.pl. */

#include "config.h"

#include "stamp-pdbgen.h"

#include <string.h>

#include <gegl.h>

#include <gdk-pixbuf/gdk-pixbuf.h>

#include "libpikabase/pikabase.h"

#include "pdb-types.h"

#include "core/pikaimage-undo-push.h"
#include "core/pikaimage.h"
#include "core/pikalayer.h"
#include "core/pikalist.h"
#include "core/pikaparamspecs.h"
#include "text/pikatext-vectors.h"
#include "text/pikatextlayer.h"
#include "vectors/pikaanchor.h"
#include "vectors/pikabezierstroke.h"
#include "vectors/pikastroke-new.h"
#include "vectors/pikavectors-export.h"
#include "vectors/pikavectors-import.h"
#include "vectors/pikavectors.h"

#include "pikapdb.h"
#include "pikapdb-utils.h"
#include "pikaprocedure.h"
#include "internal-procs.h"

#include "pika-intl.h"


static PikaValueArray *
vectors_new_invoker (PikaProcedure         *procedure,
                     Pika                  *pika,
                     PikaContext           *context,
                     PikaProgress          *progress,
                     const PikaValueArray  *args,
                     GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  const gchar *name;
  PikaVectors *vectors = NULL;

  image = g_value_get_object (pika_value_array_index (args, 0));
  name = g_value_get_string (pika_value_array_index (args, 1));

  if (success)
    {
      vectors = pika_vectors_new (image, name);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_object (pika_value_array_index (return_vals, 1), vectors);

  return return_vals;
}

static PikaValueArray *
vectors_new_from_text_layer_invoker (PikaProcedure         *procedure,
                                     Pika                  *pika,
                                     PikaContext           *context,
                                     PikaProgress          *progress,
                                     const PikaValueArray  *args,
                                     GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  PikaLayer *layer;
  PikaVectors *vectors = NULL;

  image = g_value_get_object (pika_value_array_index (args, 0));
  layer = g_value_get_object (pika_value_array_index (args, 1));

  if (success)
    {
      if (pika_pdb_layer_is_text_layer (layer, 0, error))
        {
          gint x, y;

          vectors = pika_text_vectors_new (image,
                                           pika_text_layer_get_text (PIKA_TEXT_LAYER (layer)));

          pika_item_get_offset (PIKA_ITEM (layer), &x, &y);
          pika_item_translate (PIKA_ITEM (vectors), x, y, FALSE);
        }
      else
        {
          success = FALSE;
        }
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_object (pika_value_array_index (return_vals, 1), vectors);

  return return_vals;
}

static PikaValueArray *
vectors_copy_invoker (PikaProcedure         *procedure,
                      Pika                  *pika,
                      PikaContext           *context,
                      PikaProgress          *progress,
                      const PikaValueArray  *args,
                      GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  PikaVectors *vectors_copy = NULL;

  vectors = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      vectors_copy = PIKA_VECTORS (pika_item_duplicate (PIKA_ITEM (vectors),
                                   G_TYPE_FROM_INSTANCE (vectors)));

      if (! vectors_copy)
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_object (pika_value_array_index (return_vals, 1), vectors_copy);

  return return_vals;
}

static PikaValueArray *
vectors_get_strokes_invoker (PikaProcedure         *procedure,
                             Pika                  *pika,
                             PikaContext           *context,
                             PikaProgress          *progress,
                             const PikaValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gint num_strokes = 0;
  gint32 *stroke_ids = NULL;

  vectors = g_value_get_object (pika_value_array_index (args, 0));

  if (success)
    {
      num_strokes = pika_vectors_get_n_strokes (vectors);

      if (num_strokes)
        {
          PikaStroke *cur_stroke;
          gint        i = 0;

          stroke_ids = g_new (gint32, num_strokes);

          for (cur_stroke = pika_vectors_stroke_get_next (vectors, NULL);
               cur_stroke;
               cur_stroke = pika_vectors_stroke_get_next (vectors, cur_stroke))
            {
              stroke_ids[i] = pika_stroke_get_id (cur_stroke);
              i++;
            }
        }
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (pika_value_array_index (return_vals, 1), num_strokes);
      pika_value_take_int32_array (pika_value_array_index (return_vals, 2), stroke_ids, num_strokes);
    }

  return return_vals;
}

static PikaValueArray *
vectors_stroke_get_length_invoker (PikaProcedure         *procedure,
                                   Pika                  *pika,
                                   PikaContext           *context,
                                   PikaProgress          *progress,
                                   const PikaValueArray  *args,
                                   GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble precision;
  gdouble length = 0.0;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  precision = g_value_get_double (pika_value_array_index (args, 2));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id, 0, error);

      if (stroke)
        length = pika_stroke_get_length (stroke, precision);
      else
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_double (pika_value_array_index (return_vals, 1), length);

  return return_vals;
}

static PikaValueArray *
vectors_stroke_get_point_at_dist_invoker (PikaProcedure         *procedure,
                                          Pika                  *pika,
                                          PikaContext           *context,
                                          PikaProgress          *progress,
                                          const PikaValueArray  *args,
                                          GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble dist;
  gdouble precision;
  gdouble x_point = 0.0;
  gdouble y_point = 0.0;
  gdouble slope = 0.0;
  gboolean valid = FALSE;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  dist = g_value_get_double (pika_value_array_index (args, 2));
  precision = g_value_get_double (pika_value_array_index (args, 3));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id, 0, error);

      if (stroke)
        {
          PikaCoords coord;

          valid = pika_stroke_get_point_at_dist (stroke, dist, precision,
                                                 &coord, &slope);
          x_point = valid ? coord.x : 0;
          y_point = valid ? coord.y : 0;
        }
      else
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_double (pika_value_array_index (return_vals, 1), x_point);
      g_value_set_double (pika_value_array_index (return_vals, 2), y_point);
      g_value_set_double (pika_value_array_index (return_vals, 3), slope);
      g_value_set_boolean (pika_value_array_index (return_vals, 4), valid);
    }

  return return_vals;
}

static PikaValueArray *
vectors_remove_stroke_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT, error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Remove path stroke"),
                                              vectors);

          pika_vectors_stroke_remove (vectors, stroke);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_close_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT, error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Close path stroke"),
                                              vectors);

          pika_vectors_freeze (vectors);
          pika_stroke_close (stroke);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_reverse_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT, error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Reverse path stroke"),
                                              vectors);

          pika_vectors_freeze (vectors);
          pika_stroke_reverse (stroke);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_translate_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble off_x;
  gdouble off_y;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  off_x = g_value_get_double (pika_value_array_index (args, 2));
  off_y = g_value_get_double (pika_value_array_index (args, 3));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT |
                                                        PIKA_PDB_ITEM_POSITION,
                                                        error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Translate path stroke"),
                                              vectors);

          pika_vectors_freeze (vectors);
          pika_stroke_translate (stroke, off_x, off_y);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_scale_invoker (PikaProcedure         *procedure,
                              Pika                  *pika,
                              PikaContext           *context,
                              PikaProgress          *progress,
                              const PikaValueArray  *args,
                              GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble scale_x;
  gdouble scale_y;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  scale_x = g_value_get_double (pika_value_array_index (args, 2));
  scale_y = g_value_get_double (pika_value_array_index (args, 3));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT |
                                                        PIKA_PDB_ITEM_POSITION,
                                                        error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Scale path stroke"),
                                              vectors);

          pika_vectors_freeze (vectors);
          pika_stroke_scale (stroke, scale_x, scale_y);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_rotate_invoker (PikaProcedure         *procedure,
                               Pika                  *pika,
                               PikaContext           *context,
                               PikaProgress          *progress,
                               const PikaValueArray  *args,
                               GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble center_x;
  gdouble center_y;
  gdouble angle;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  center_x = g_value_get_double (pika_value_array_index (args, 2));
  center_y = g_value_get_double (pika_value_array_index (args, 3));
  angle = g_value_get_double (pika_value_array_index (args, 4));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT |
                                                        PIKA_PDB_ITEM_POSITION,
                                                        error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Rotate path stroke"),
                                              vectors);

          pika_vectors_freeze (vectors);
          pika_stroke_rotate (stroke, center_x, center_y, angle);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_flip_invoker (PikaProcedure         *procedure,
                             Pika                  *pika,
                             PikaContext           *context,
                             PikaProgress          *progress,
                             const PikaValueArray  *args,
                             GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gint flip_type;
  gdouble axis;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  flip_type = g_value_get_enum (pika_value_array_index (args, 2));
  axis = g_value_get_double (pika_value_array_index (args, 3));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT |
                                                        PIKA_PDB_ITEM_POSITION,
                                                        error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Flip path stroke"),
                                              vectors);

          pika_vectors_freeze (vectors);
          pika_stroke_flip (stroke, flip_type, axis);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_flip_free_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble x1;
  gdouble y1;
  gdouble x2;
  gdouble y2;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  x1 = g_value_get_double (pika_value_array_index (args, 2));
  y1 = g_value_get_double (pika_value_array_index (args, 3));
  x2 = g_value_get_double (pika_value_array_index (args, 4));
  y2 = g_value_get_double (pika_value_array_index (args, 5));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT |
                                                        PIKA_PDB_ITEM_POSITION,
                                                        error);

      if (stroke)
        {
          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Flip path stroke"),
                                              vectors);

          pika_vectors_freeze (vectors);
          pika_stroke_flip_free (stroke, x1, y1, x2, y2);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_stroke_get_points_invoker (PikaProcedure         *procedure,
                                   Pika                  *pika,
                                   PikaContext           *context,
                                   PikaProgress          *progress,
                                   const PikaValueArray  *args,
                                   GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gint stroke_id;
  gint type = 0;
  gint num_points = 0;
  gdouble *controlpoints = NULL;
  gboolean closed = FALSE;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id, 0, error);

      if (PIKA_IS_BEZIER_STROKE (stroke))
        {
          GArray *points_array;
          gint    i;

          points_array = pika_stroke_control_points_get (stroke, &closed);

          if (points_array)
            {
              num_points = points_array->len;
              controlpoints = g_new (gdouble, num_points * 2);

              type = PIKA_VECTORS_STROKE_TYPE_BEZIER;
              for (i = 0; i < num_points; i++)
                {
                  controlpoints[2*i]   = g_array_index (points_array,
                                                        PikaAnchor, i).position.x;
                  controlpoints[2*i+1] = g_array_index (points_array,
                                                        PikaAnchor, i).position.y;
                }
              g_array_free (points_array, TRUE);
              num_points *= 2;
            }
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_enum (pika_value_array_index (return_vals, 1), type);
      g_value_set_int (pika_value_array_index (return_vals, 2), num_points);
      pika_value_take_float_array (pika_value_array_index (return_vals, 3), controlpoints, num_points);
      g_value_set_boolean (pika_value_array_index (return_vals, 4), closed);
    }

  return return_vals;
}

static PikaValueArray *
vectors_stroke_new_from_points_invoker (PikaProcedure         *procedure,
                                        Pika                  *pika,
                                        PikaContext           *context,
                                        PikaProgress          *progress,
                                        const PikaValueArray  *args,
                                        GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gint type;
  gint num_points;
  const gdouble *controlpoints;
  gboolean closed;
  gint stroke_id = 0;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  type = g_value_get_enum (pika_value_array_index (args, 1));
  num_points = g_value_get_int (pika_value_array_index (args, 2));
  controlpoints = pika_value_get_float_array (pika_value_array_index (args, 3));
  closed = g_value_get_boolean (pika_value_array_index (args, 4));

  if (success)
    {
      PikaStroke *stroke;
      PikaCoords *coords;
      PikaCoords  default_coords = PIKA_COORDS_DEFAULT_VALUES;
      gint i;

      success = FALSE;

      if (type == PIKA_VECTORS_STROKE_TYPE_BEZIER &&
          num_points % 6 == 0)
        {
          coords = g_new (PikaCoords, num_points/2);
          for (i = 0; i < num_points/2; i++)
            {
              coords[i] = default_coords;
              coords[i].x = controlpoints[i*2];
              coords[i].y = controlpoints[i*2+1];
            }

          stroke = pika_stroke_new_from_coords (type, coords, num_points/2, closed);
          if (stroke)
            {
              if (pika_item_is_attached (PIKA_ITEM (vectors)))
                pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                                  _("Add path stroke"),
                                                  vectors);

              pika_vectors_stroke_add (vectors, stroke);
              g_object_unref (stroke);

              stroke_id = pika_stroke_get_id (stroke);

              success = TRUE;
            }

          g_free (coords);
        }
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_int (pika_value_array_index (return_vals, 1), stroke_id);

  return return_vals;
}

static PikaValueArray *
vectors_stroke_interpolate_invoker (PikaProcedure         *procedure,
                                    Pika                  *pika,
                                    PikaContext           *context,
                                    PikaProgress          *progress,
                                    const PikaValueArray  *args,
                                    GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble precision;
  gint num_coords = 0;
  gdouble *coords = NULL;
  gboolean closed = FALSE;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  precision = g_value_get_double (pika_value_array_index (args, 2));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id, 0, error);

      if (stroke)
        {
          GArray *coords_array;
          gint    i;

          coords_array = pika_stroke_interpolate (stroke, precision, &closed);

          if (coords_array)
            {
              num_coords = coords_array->len;
              coords = g_new (gdouble, num_coords * 2);

              for (i = 0; i < num_coords; i++)
                {
                  coords[2*i]   = g_array_index (coords_array, PikaCoords, i).x;
                  coords[2*i+1] = g_array_index (coords_array, PikaCoords, i).y;
                }
              g_array_free (coords_array, TRUE);
              num_coords *= 2;
            }
          else
            success = FALSE;
        }
      else
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (pika_value_array_index (return_vals, 1), num_coords);
      pika_value_take_float_array (pika_value_array_index (return_vals, 2), coords, num_coords);
      g_value_set_boolean (pika_value_array_index (return_vals, 3), closed);
    }

  return return_vals;
}

static PikaValueArray *
vectors_bezier_stroke_new_moveto_invoker (PikaProcedure         *procedure,
                                          Pika                  *pika,
                                          PikaContext           *context,
                                          PikaProgress          *progress,
                                          const PikaValueArray  *args,
                                          GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gdouble x0;
  gdouble y0;
  gint stroke_id = 0;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  x0 = g_value_get_double (pika_value_array_index (args, 1));
  y0 = g_value_get_double (pika_value_array_index (args, 2));

  if (success)
    {
      if (pika_pdb_item_is_modifiable (PIKA_ITEM (vectors),
                                       PIKA_PDB_ITEM_CONTENT, error) &&
          pika_pdb_item_is_not_group (PIKA_ITEM (vectors), error))
        {
          PikaStroke *stroke;
          PikaCoords  coord0 = PIKA_COORDS_DEFAULT_VALUES;

          coord0.x = x0;
          coord0.y = y0;

          stroke = pika_bezier_stroke_new_moveto (&coord0);

          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Add path stroke"),
                                              vectors);

          pika_vectors_stroke_add (vectors, stroke);
          g_object_unref (stroke);

          stroke_id = pika_stroke_get_id (stroke);
        }
      else
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_int (pika_value_array_index (return_vals, 1), stroke_id);

  return return_vals;
}

static PikaValueArray *
vectors_bezier_stroke_lineto_invoker (PikaProcedure         *procedure,
                                      Pika                  *pika,
                                      PikaContext           *context,
                                      PikaProgress          *progress,
                                      const PikaValueArray  *args,
                                      GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble x0;
  gdouble y0;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  x0 = g_value_get_double (pika_value_array_index (args, 2));
  y0 = g_value_get_double (pika_value_array_index (args, 3));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT, error);

      if (stroke)
        {
          PikaCoords coord0 = PIKA_COORDS_DEFAULT_VALUES;

          coord0.x = x0;
          coord0.y = y0;

         if (pika_item_is_attached (PIKA_ITEM (vectors)))
           pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                             _("Extend path stroke"),
                                             vectors);

          pika_vectors_freeze (vectors);
          pika_bezier_stroke_lineto (stroke, &coord0);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_bezier_stroke_conicto_invoker (PikaProcedure         *procedure,
                                       Pika                  *pika,
                                       PikaContext           *context,
                                       PikaProgress          *progress,
                                       const PikaValueArray  *args,
                                       GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble x0;
  gdouble y0;
  gdouble x1;
  gdouble y1;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  x0 = g_value_get_double (pika_value_array_index (args, 2));
  y0 = g_value_get_double (pika_value_array_index (args, 3));
  x1 = g_value_get_double (pika_value_array_index (args, 4));
  y1 = g_value_get_double (pika_value_array_index (args, 5));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT, error);

      if (stroke)
        {
          PikaCoords coord0 = PIKA_COORDS_DEFAULT_VALUES;
          PikaCoords coord1 = PIKA_COORDS_DEFAULT_VALUES;

          coord0.x = x0;
          coord0.y = y0;

          coord1.x = x1;
          coord1.y = y1;

         if (pika_item_is_attached (PIKA_ITEM (vectors)))
           pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                             _("Extend path stroke"),
                                             vectors);

          pika_vectors_freeze (vectors);
          pika_bezier_stroke_conicto (stroke, &coord0, &coord1);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_bezier_stroke_cubicto_invoker (PikaProcedure         *procedure,
                                       Pika                  *pika,
                                       PikaContext           *context,
                                       PikaProgress          *progress,
                                       const PikaValueArray  *args,
                                       GError               **error)
{
  gboolean success = TRUE;
  PikaVectors *vectors;
  gint stroke_id;
  gdouble x0;
  gdouble y0;
  gdouble x1;
  gdouble y1;
  gdouble x2;
  gdouble y2;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  stroke_id = g_value_get_int (pika_value_array_index (args, 1));
  x0 = g_value_get_double (pika_value_array_index (args, 2));
  y0 = g_value_get_double (pika_value_array_index (args, 3));
  x1 = g_value_get_double (pika_value_array_index (args, 4));
  y1 = g_value_get_double (pika_value_array_index (args, 5));
  x2 = g_value_get_double (pika_value_array_index (args, 6));
  y2 = g_value_get_double (pika_value_array_index (args, 7));

  if (success)
    {
      PikaStroke *stroke = pika_pdb_get_vectors_stroke (vectors, stroke_id,
                                                        PIKA_PDB_ITEM_CONTENT, error);

      if (stroke)
        {
          PikaCoords coord0 = PIKA_COORDS_DEFAULT_VALUES;
          PikaCoords coord1 = PIKA_COORDS_DEFAULT_VALUES;
          PikaCoords coord2 = PIKA_COORDS_DEFAULT_VALUES;

          coord0.x = x0;
          coord0.y = y0;

          coord1.x = x1;
          coord1.y = y1;

          coord2.x = x2;
          coord2.y = y2;

         if (pika_item_is_attached (PIKA_ITEM (vectors)))
           pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                             _("Extend path stroke"),
                                             vectors);

          pika_vectors_freeze (vectors);
          pika_bezier_stroke_cubicto (stroke, &coord0, &coord1, &coord2);
          pika_vectors_thaw (vectors);
        }
      else
        success = FALSE;
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_bezier_stroke_new_ellipse_invoker (PikaProcedure         *procedure,
                                           Pika                  *pika,
                                           PikaContext           *context,
                                           PikaProgress          *progress,
                                           const PikaValueArray  *args,
                                           GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaVectors *vectors;
  gdouble x0;
  gdouble y0;
  gdouble radius_x;
  gdouble radius_y;
  gdouble angle;
  gint stroke_id = 0;

  vectors = g_value_get_object (pika_value_array_index (args, 0));
  x0 = g_value_get_double (pika_value_array_index (args, 1));
  y0 = g_value_get_double (pika_value_array_index (args, 2));
  radius_x = g_value_get_double (pika_value_array_index (args, 3));
  radius_y = g_value_get_double (pika_value_array_index (args, 4));
  angle = g_value_get_double (pika_value_array_index (args, 5));

  if (success)
    {
      if (pika_pdb_item_is_modifiable (PIKA_ITEM (vectors),
                                       PIKA_PDB_ITEM_CONTENT, error) &&
          pika_pdb_item_is_not_group (PIKA_ITEM (vectors), error))
        {
          PikaStroke *stroke;
          PikaCoords  coord0 = PIKA_COORDS_DEFAULT_VALUES;

          coord0.x = x0;
          coord0.y = y0;

          stroke = pika_bezier_stroke_new_ellipse (&coord0, radius_x, radius_y, angle);

          if (pika_item_is_attached (PIKA_ITEM (vectors)))
            pika_image_undo_push_vectors_mod (pika_item_get_image (PIKA_ITEM (vectors)),
                                              _("Add path stroke"),
                                              vectors);

          pika_vectors_stroke_add (vectors, stroke);
          g_object_unref (stroke);

          stroke_id = pika_stroke_get_id (stroke);
        }
      else
        success = FALSE;
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_set_int (pika_value_array_index (return_vals, 1), stroke_id);

  return return_vals;
}

static PikaValueArray *
vectors_import_from_file_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  GFile *file;
  gboolean merge;
  gboolean scale;
  gint num_vectors = 0;
  PikaVectors **vectors = NULL;

  image = g_value_get_object (pika_value_array_index (args, 0));
  file = g_value_get_object (pika_value_array_index (args, 1));
  merge = g_value_get_boolean (pika_value_array_index (args, 2));
  scale = g_value_get_boolean (pika_value_array_index (args, 3));

  if (success)
    {
      GList *vectors_list = NULL;

      /* FIXME tree */
      success = pika_vectors_import_file (image, file,
                                          merge, scale, NULL, -1,
                                          &vectors_list, error);

      if (success)
        {
          num_vectors = g_list_length (vectors_list);

          if (num_vectors)
            {
              GList *list;
              gint   i;

              vectors = g_new (PikaVectors *, num_vectors);

              for (i = 0, list = vectors_list;
                   i < num_vectors;
                   i++, list = g_list_next (list))
                {
                  vectors[i] = g_object_ref (list->data);
                }

              g_list_free (vectors_list);
            }
        }
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (pika_value_array_index (return_vals, 1), num_vectors);
      pika_value_take_object_array (pika_value_array_index (return_vals, 2), PIKA_TYPE_VECTORS, (GObject **) vectors, num_vectors);
    }

  return return_vals;
}

static PikaValueArray *
vectors_import_from_string_invoker (PikaProcedure         *procedure,
                                    Pika                  *pika,
                                    PikaContext           *context,
                                    PikaProgress          *progress,
                                    const PikaValueArray  *args,
                                    GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  const gchar *string;
  gint length;
  gboolean merge;
  gboolean scale;
  gint num_vectors = 0;
  PikaVectors **vectors = NULL;

  image = g_value_get_object (pika_value_array_index (args, 0));
  string = g_value_get_string (pika_value_array_index (args, 1));
  length = g_value_get_int (pika_value_array_index (args, 2));
  merge = g_value_get_boolean (pika_value_array_index (args, 3));
  scale = g_value_get_boolean (pika_value_array_index (args, 4));

  if (success)
    {
      GList *vectors_list = NULL;

      /* FIXME tree */
      success = pika_vectors_import_buffer (image, string, length,
                                            merge, scale, NULL, -1,
                                            &vectors_list, error);

      if (success)
        {
          num_vectors = g_list_length (vectors_list);

          if (num_vectors)
            {
              GList *list;
              gint   i;

              vectors = g_new (PikaVectors *, num_vectors);

              for (i = 0, list = vectors_list;
                   i < num_vectors;
                   i++, list = g_list_next (list))
                {
                  vectors[i] = g_object_ref (list->data);
                }

              g_list_free (vectors_list);
            }
        }
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    {
      g_value_set_int (pika_value_array_index (return_vals, 1), num_vectors);
      pika_value_take_object_array (pika_value_array_index (return_vals, 2), PIKA_TYPE_VECTORS, (GObject **) vectors, num_vectors);
    }

  return return_vals;
}

static PikaValueArray *
vectors_export_to_file_invoker (PikaProcedure         *procedure,
                                Pika                  *pika,
                                PikaContext           *context,
                                PikaProgress          *progress,
                                const PikaValueArray  *args,
                                GError               **error)
{
  gboolean success = TRUE;
  PikaImage *image;
  GFile *file;
  PikaVectors *vectors;

  image = g_value_get_object (pika_value_array_index (args, 0));
  file = g_value_get_object (pika_value_array_index (args, 1));
  vectors = g_value_get_object (pika_value_array_index (args, 2));

  if (success)
    {
      GList *vectors_list = g_list_prepend (NULL, vectors);

      success = pika_vectors_export_file (image, vectors_list, file, error);

      g_list_free (vectors_list);
    }

  return pika_procedure_get_return_values (procedure, success,
                                           error ? *error : NULL);
}

static PikaValueArray *
vectors_export_to_string_invoker (PikaProcedure         *procedure,
                                  Pika                  *pika,
                                  PikaContext           *context,
                                  PikaProgress          *progress,
                                  const PikaValueArray  *args,
                                  GError               **error)
{
  gboolean success = TRUE;
  PikaValueArray *return_vals;
  PikaImage *image;
  PikaVectors *vectors;
  gchar *string = NULL;

  image = g_value_get_object (pika_value_array_index (args, 0));
  vectors = g_value_get_object (pika_value_array_index (args, 1));

  if (success)
    {
      GList *vectors_list = g_list_prepend (NULL, vectors);

      string = pika_vectors_export_string (image, vectors_list);
      g_list_free (vectors_list);

      success = (string != NULL);
    }

  return_vals = pika_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);

  if (success)
    g_value_take_string (pika_value_array_index (return_vals, 1), string);

  return return_vals;
}

void
register_vectors_procs (PikaPDB *pdb)
{
  PikaProcedure *procedure;

  /*
   * pika-vectors-new
   */
  procedure = pika_procedure_new (vectors_new_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-new");
  pika_procedure_set_static_help (procedure,
                                  "Creates a new empty vectors object.",
                                  "Creates a new empty vectors object. The vectors object needs to be added to the image using 'pika-image-insert-vectors'.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("name",
                                                       "name",
                                                       "the name of the new vector object.",
                                                       FALSE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_vectors ("vectors",
                                                            "vectors",
                                                            "the current vector object, 0 if no vector exists in the image.",
                                                            FALSE,
                                                            PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-new-from-text-layer
   */
  procedure = pika_procedure_new (vectors_new_from_text_layer_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-new-from-text-layer");
  pika_procedure_set_static_help (procedure,
                                  "Creates a new vectors object from a text layer.",
                                  "Creates a new vectors object from a text layer. The vectors object needs to be added to the image using 'pika-image-insert-vectors'.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Marcus Heese <heese@cip.ifi.lmu.de>",
                                         "Marcus Heese",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image.",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_layer ("layer",
                                                      "layer",
                                                      "The text layer.",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_vectors ("vectors",
                                                            "vectors",
                                                            "The vectors of the text layer.",
                                                            FALSE,
                                                            PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-copy
   */
  procedure = pika_procedure_new (vectors_copy_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-copy");
  pika_procedure_set_static_help (procedure,
                                  "Copy a vectors object.",
                                  "This procedure copies the specified vectors object and returns the copy.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Barak Itkin <lightningismyname@gmail.com>",
                                         "Barak Itkin",
                                         "2008");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object to copy",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_vectors ("vectors-copy",
                                                            "vectors copy",
                                                            "The newly copied vectors object",
                                                            FALSE,
                                                            PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-get-strokes
   */
  procedure = pika_procedure_new (vectors_get_strokes_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-get-strokes");
  pika_procedure_set_static_help (procedure,
                                  "List the strokes associated with the passed path.",
                                  "Returns an Array with the stroke-IDs associated with the passed path.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("num-strokes",
                                                     "num strokes",
                                                     "The number of strokes returned.",
                                                     0, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_int32_array ("stroke-ids",
                                                                "stroke ids",
                                                                "List of the strokes belonging to the path.",
                                                                PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-get-length
   */
  procedure = pika_procedure_new (vectors_stroke_get_length_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-get-length");
  pika_procedure_set_static_help (procedure,
                                  "Measure the length of the given stroke.",
                                  "Measure the length of the given stroke.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("precision",
                                                    "precision",
                                                    "The precision used for approximating straight portions of the stroke",
                                                    0.0, G_MAXDOUBLE, 0.1,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("length",
                                                        "length",
                                                        "The length (in pixels) of the given stroke.",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-get-point-at-dist
   */
  procedure = pika_procedure_new (vectors_stroke_get_point_at_dist_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-get-point-at-dist");
  pika_procedure_set_static_help (procedure,
                                  "Get point at a specified distance along the stroke.",
                                  "This will return the x,y position of a point at a given distance along the stroke. The distance will be obtained by first digitizing the curve internally and then walking along the curve. For a closed stroke the start of the path is the first point on the path that was created. This might not be obvious. If the stroke is not long enough, a \"valid\" flag will be FALSE.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("dist",
                                                    "dist",
                                                    "The given distance.",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("precision",
                                                    "precision",
                                                    "The precision used for the approximation",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("x-point",
                                                        "x point",
                                                        "The x position of the point.",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("y-point",
                                                        "y point",
                                                        "The y position of the point.",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_double ("slope",
                                                        "slope",
                                                        "The slope (dy / dx) at the specified point.",
                                                        -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("valid",
                                                         "valid",
                                                         "Indicator for the validity of the returned data.",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-remove-stroke
   */
  procedure = pika_procedure_new (vectors_remove_stroke_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-remove-stroke");
  pika_procedure_set_static_help (procedure,
                                  "remove the stroke from a vectors object.",
                                  "Remove the stroke from a vectors object.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-close
   */
  procedure = pika_procedure_new (vectors_stroke_close_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-close");
  pika_procedure_set_static_help (procedure,
                                  "closes the specified stroke.",
                                  "Closes the specified stroke.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-reverse
   */
  procedure = pika_procedure_new (vectors_stroke_reverse_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-reverse");
  pika_procedure_set_static_help (procedure,
                                  "reverses the specified stroke.",
                                  "Reverses the specified stroke.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2020");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-translate
   */
  procedure = pika_procedure_new (vectors_stroke_translate_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-translate");
  pika_procedure_set_static_help (procedure,
                                  "translate the given stroke.",
                                  "Translate the given stroke.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("off-x",
                                                    "off x",
                                                    "Offset in x direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("off-y",
                                                    "off y",
                                                    "Offset in y direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-scale
   */
  procedure = pika_procedure_new (vectors_stroke_scale_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-scale");
  pika_procedure_set_static_help (procedure,
                                  "scales the given stroke.",
                                  "Scale the given stroke.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("scale-x",
                                                    "scale x",
                                                    "Scale factor in x direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("scale-y",
                                                    "scale y",
                                                    "Scale factor in y direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-rotate
   */
  procedure = pika_procedure_new (vectors_stroke_rotate_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-rotate");
  pika_procedure_set_static_help (procedure,
                                  "rotates the given stroke.",
                                  "Rotates the given stroke around given center by angle (in degrees).",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jo\xc3\xa3o S. O. Bueno",
                                         "Jo\xc3\xa3o S. O. Bueno",
                                         "2006");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("center-x",
                                                    "center x",
                                                    "X coordinate of the rotation center",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("center-y",
                                                    "center y",
                                                    "Y coordinate of the rotation center",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("angle",
                                                    "angle",
                                                    "angle to rotate about",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-flip
   */
  procedure = pika_procedure_new (vectors_stroke_flip_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-flip");
  pika_procedure_set_static_help (procedure,
                                  "flips the given stroke.",
                                  "Rotates the given stroke around given center by angle (in degrees).",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jo\xc3\xa3o S. O. Bueno",
                                         "Jo\xc3\xa3o S. O. Bueno",
                                         "2006");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_enum ("flip-type",
                                                     "flip type",
                                                     "Flip orientation, either vertical or horizontal",
                                                     PIKA_TYPE_ORIENTATION_TYPE,
                                                     PIKA_ORIENTATION_HORIZONTAL,
                                                     PIKA_PARAM_READWRITE));
  pika_param_spec_enum_exclude_value (PIKA_PARAM_SPEC_ENUM (procedure->args[2]),
                                      PIKA_ORIENTATION_UNKNOWN);
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("axis",
                                                    "axis",
                                                    "axis coordinate about which to flip, in pixels",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-flip-free
   */
  procedure = pika_procedure_new (vectors_stroke_flip_free_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-flip-free");
  pika_procedure_set_static_help (procedure,
                                  "flips the given stroke about an arbitrary axis.",
                                  "Flips the given stroke about an arbitrary axis. Axis is defined by two coordinates in the image (in pixels), through which the flipping axis passes.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Jo\xc3\xa3o S. O. Bueno",
                                         "Jo\xc3\xa3o S. O. Bueno",
                                         "2006");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x1",
                                                    "x1",
                                                    "X coordinate of the first point of the flipping axis",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y1",
                                                    "y1",
                                                    "Y coordinate of the first point of the flipping axis",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x2",
                                                    "x2",
                                                    "X coordinate of the second point of the flipping axis",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y2",
                                                    "y2",
                                                    "Y coordinate of the second point of the flipping axis",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-get-points
   */
  procedure = pika_procedure_new (vectors_stroke_get_points_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-get-points");
  pika_procedure_set_static_help (procedure,
                                  "returns the control points of a stroke.",
                                  "returns the control points of a stroke. The interpretation of the coordinates returned depends on the type of the stroke. For Pika 2.4 this is always a bezier stroke, where the coordinates are the control points.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2006");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_enum ("type",
                                                      "type",
                                                      "type of the stroke (always PIKA_VECTORS_STROKE_TYPE_BEZIER for now).",
                                                      PIKA_TYPE_VECTORS_STROKE_TYPE,
                                                      PIKA_VECTORS_STROKE_TYPE_BEZIER,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("num-points",
                                                     "num points",
                                                     "The number of floats returned.",
                                                     0, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_float_array ("controlpoints",
                                                                "controlpoints",
                                                                "List of the control points for the stroke (x0, y0, x1, y1, ...).",
                                                                PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("closed",
                                                         "closed",
                                                         "Whether the stroke is closed or not.",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-new-from-points
   */
  procedure = pika_procedure_new (vectors_stroke_new_from_points_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-new-from-points");
  pika_procedure_set_static_help (procedure,
                                  "Adds a stroke of a given type to the vectors object.",
                                  "Adds a stroke of a given type to the vectors object. The coordinates of the control points can be specified. For now only strokes of the type PIKA_VECTORS_STROKE_TYPE_BEZIER are supported. The control points are specified as a pair of float values for the x- and y-coordinate. The Bezier stroke type needs a multiple of three control points. Each Bezier segment endpoint (anchor, A) has two additional control points (C) associated. They are specified in the order CACCACCAC...",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2006");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_enum ("type",
                                                  "type",
                                                  "type of the stroke (always PIKA_VECTORS_STROKE_TYPE_BEZIER for now).",
                                                  PIKA_TYPE_VECTORS_STROKE_TYPE,
                                                  PIKA_VECTORS_STROKE_TYPE_BEZIER,
                                                  PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("num-points",
                                                 "num points",
                                                 "The number of elements in the array, i.e. the number of controlpoints in the stroke * 2 (x- and y-coordinate).",
                                                 0, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_float_array ("controlpoints",
                                                            "controlpoints",
                                                            "List of the x- and y-coordinates of the control points.",
                                                            PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("closed",
                                                     "closed",
                                                     "Whether the stroke is to be closed or not.",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("stroke-id",
                                                     "stroke id",
                                                     "The stroke ID of the newly created stroke.",
                                                     G_MININT32, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-stroke-interpolate
   */
  procedure = pika_procedure_new (vectors_stroke_interpolate_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-stroke-interpolate");
  pika_procedure_set_static_help (procedure,
                                  "returns polygonal approximation of the stroke.",
                                  "returns polygonal approximation of the stroke.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("precision",
                                                    "precision",
                                                    "The precision used for the approximation",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("num-coords",
                                                     "num coords",
                                                     "The number of floats returned.",
                                                     0, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_float_array ("coords",
                                                                "coords",
                                                                "List of the coords along the path (x0, y0, x1, y1, ...).",
                                                                PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_boolean ("closed",
                                                         "closed",
                                                         "Whether the stroke is closed or not.",
                                                         FALSE,
                                                         PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-bezier-stroke-new-moveto
   */
  procedure = pika_procedure_new (vectors_bezier_stroke_new_moveto_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-bezier-stroke-new-moveto");
  pika_procedure_set_static_help (procedure,
                                  "Adds a bezier stroke with a single moveto to the vectors object.",
                                  "Adds a bezier stroke with a single moveto to the vectors object.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x0",
                                                    "x0",
                                                    "The x-coordinate of the moveto",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y0",
                                                    "y0",
                                                    "The y-coordinate of the moveto",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("stroke-id",
                                                     "stroke id",
                                                     "The resulting stroke",
                                                     G_MININT32, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-bezier-stroke-lineto
   */
  procedure = pika_procedure_new (vectors_bezier_stroke_lineto_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-bezier-stroke-lineto");
  pika_procedure_set_static_help (procedure,
                                  "Extends a bezier stroke with a lineto.",
                                  "Extends a bezier stroke with a lineto.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x0",
                                                    "x0",
                                                    "The x-coordinate of the lineto",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y0",
                                                    "y0",
                                                    "The y-coordinate of the lineto",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-bezier-stroke-conicto
   */
  procedure = pika_procedure_new (vectors_bezier_stroke_conicto_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-bezier-stroke-conicto");
  pika_procedure_set_static_help (procedure,
                                  "Extends a bezier stroke with a conic bezier spline.",
                                  "Extends a bezier stroke with a conic bezier spline. Actually a cubic bezier spline gets added that realizes the shape of a conic bezier spline.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x0",
                                                    "x0",
                                                    "The x-coordinate of the control point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y0",
                                                    "y0",
                                                    "The y-coordinate of the control point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x1",
                                                    "x1",
                                                    "The x-coordinate of the end point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y1",
                                                    "y1",
                                                    "The y-coordinate of the end point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-bezier-stroke-cubicto
   */
  procedure = pika_procedure_new (vectors_bezier_stroke_cubicto_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-bezier-stroke-cubicto");
  pika_procedure_set_static_help (procedure,
                                  "Extends a bezier stroke with a cubic bezier spline.",
                                  "Extends a bezier stroke with a cubic bezier spline.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("stroke-id",
                                                 "stroke id",
                                                 "The stroke ID",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x0",
                                                    "x0",
                                                    "The x-coordinate of the first control point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y0",
                                                    "y0",
                                                    "The y-coordinate of the first control point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x1",
                                                    "x1",
                                                    "The x-coordinate of the second control point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y1",
                                                    "y1",
                                                    "The y-coordinate of the second control point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x2",
                                                    "x2",
                                                    "The x-coordinate of the end point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y2",
                                                    "y2",
                                                    "The y-coordinate of the end point",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-bezier-stroke-new-ellipse
   */
  procedure = pika_procedure_new (vectors_bezier_stroke_new_ellipse_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-bezier-stroke-new-ellipse");
  pika_procedure_set_static_help (procedure,
                                  "Adds a bezier stroke describing an ellipse the vectors object.",
                                  "Adds a bezier stroke describing an ellipse the vectors object.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2005");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("x0",
                                                    "x0",
                                                    "The x-coordinate of the center",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("y0",
                                                    "y0",
                                                    "The y-coordinate of the center",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("radius-x",
                                                    "radius x",
                                                    "The radius in x direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("radius-y",
                                                    "radius y",
                                                    "The radius in y direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_double ("angle",
                                                    "angle",
                                                    "The angle the x-axis of the ellipse (radians, counterclockwise)",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("stroke-id",
                                                     "stroke id",
                                                     "The resulting stroke",
                                                     G_MININT32, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-import-from-file
   */
  procedure = pika_procedure_new (vectors_import_from_file_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-import-from-file");
  pika_procedure_set_static_help (procedure,
                                  "Import paths from an SVG file.",
                                  "This procedure imports paths from an SVG file. SVG elements other than paths and basic shapes are ignored.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2006");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_object ("file",
                                                    "file",
                                                    "The SVG file to import.",
                                                    G_TYPE_FILE,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("merge",
                                                     "merge",
                                                     "Merge paths into a single vectors object.",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("scale",
                                                     "scale",
                                                     "Scale the SVG to image dimensions.",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("num-vectors",
                                                     "num vectors",
                                                     "The number of newly created vectors",
                                                     0, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_object_array ("vectors",
                                                                 "vectors",
                                                                 "The list of newly created vectors",
                                                                 PIKA_TYPE_VECTORS,
                                                                 PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-import-from-string
   */
  procedure = pika_procedure_new (vectors_import_from_string_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-import-from-string");
  pika_procedure_set_static_help (procedure,
                                  "Import paths from an SVG string.",
                                  "This procedure works like 'pika-vectors-import-from-file' but takes a string rather than reading the SVG from a file. This allows you to write scripts that generate SVG and feed it to PIKA.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Simon Budig",
                                         "Simon Budig",
                                         "2006");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_string ("string",
                                                       "string",
                                                       "A string that must be a complete and valid SVG document.",
                                                       TRUE, FALSE, FALSE,
                                                       NULL,
                                                       PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_int ("length",
                                                 "length",
                                                 "Number of bytes in string or -1 if the string is NULL terminated.",
                                                 G_MININT32, G_MAXINT32, 0,
                                                 PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("merge",
                                                     "merge",
                                                     "Merge paths into a single vectors object.",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_boolean ("scale",
                                                     "scale",
                                                     "Scale the SVG to image dimensions.",
                                                     FALSE,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   g_param_spec_int ("num-vectors",
                                                     "num vectors",
                                                     "The number of newly created vectors",
                                                     0, G_MAXINT32, 0,
                                                     PIKA_PARAM_READWRITE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_object_array ("vectors",
                                                                 "vectors",
                                                                 "The list of newly created vectors",
                                                                 PIKA_TYPE_VECTORS,
                                                                 PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-export-to-file
   */
  procedure = pika_procedure_new (vectors_export_to_file_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-export-to-file");
  pika_procedure_set_static_help (procedure,
                                  "save a path as an SVG file.",
                                  "This procedure creates an SVG file to save a Vectors object, that is, a path. The resulting file can be edited using a vector graphics application, or later reloaded into PIKA. If you pass 0 as the 'vectors' argument, then all paths in the image will be exported.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Bill Skaggs <weskaggs@primate.ucdavis.edu>",
                                         "Bill Skaggs",
                                         "2007");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               g_param_spec_object ("file",
                                                    "file",
                                                    "The SVG file to create.",
                                                    G_TYPE_FILE,
                                                    PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object to be saved, or 0 for all in the image",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);

  /*
   * pika-vectors-export-to-string
   */
  procedure = pika_procedure_new (vectors_export_to_string_invoker);
  pika_object_set_static_name (PIKA_OBJECT (procedure),
                               "pika-vectors-export-to-string");
  pika_procedure_set_static_help (procedure,
                                  "Save a path as an SVG string.",
                                  "This procedure works like 'pika-vectors-export-to-file' but creates a string rather than a file. The contents are a NUL-terminated string that holds a complete XML document. If you pass 0 as the 'vectors' argument, then all paths in the image will be exported.",
                                  NULL);
  pika_procedure_set_static_attribution (procedure,
                                         "Bill Skaggs <weskaggs@primate.ucdavis.edu>",
                                         "Bill Skaggs",
                                         "2007");
  pika_procedure_add_argument (procedure,
                               pika_param_spec_image ("image",
                                                      "image",
                                                      "The image",
                                                      FALSE,
                                                      PIKA_PARAM_READWRITE));
  pika_procedure_add_argument (procedure,
                               pika_param_spec_vectors ("vectors",
                                                        "vectors",
                                                        "The vectors object to save, or 0 for all in the image",
                                                        FALSE,
                                                        PIKA_PARAM_READWRITE | PIKA_PARAM_NO_VALIDATE));
  pika_procedure_add_return_value (procedure,
                                   pika_param_spec_string ("string",
                                                           "string",
                                                           "A string whose contents are a complete SVG document.",
                                                           FALSE, FALSE, FALSE,
                                                           NULL,
                                                           PIKA_PARAM_READWRITE));
  pika_pdb_register_procedure (pdb, procedure);
  g_object_unref (procedure);
}
