2005-04-14 10:32:23 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpvectors_pdb.c
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2005-04-14 10:32:23 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2005-04-14 10:32:23 +08:00
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2005-04-14 10:32:23 +08:00
|
|
|
*/
|
|
|
|
|
2007-01-09 18:52:47 +08:00
|
|
|
/* NOTE: This file is auto-generated by pdbgen.pl */
|
2005-04-14 10:32:23 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gimp.h"
|
|
|
|
|
2010-07-07 17:43:10 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION: gimpvectors
|
|
|
|
* @title: gimpvectors
|
|
|
|
* @short_description: Functions for querying and manipulating vectors.
|
|
|
|
*
|
|
|
|
* Functions for querying and manipulating vectors.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2005-12-30 04:55:07 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_new:
|
|
|
|
* @image_ID: The image.
|
|
|
|
* @name: the name of the new vector object.
|
|
|
|
*
|
2006-03-22 20:15:06 +08:00
|
|
|
* Creates a new empty vectors object.
|
2005-12-30 04:55:07 +08:00
|
|
|
*
|
2008-04-04 22:50:42 +08:00
|
|
|
* Creates a new empty vectors object. The vectors object needs to be
|
2010-09-06 06:03:29 +08:00
|
|
|
* added to the image using gimp_image_insert_vectors().
|
2005-12-30 04:55:07 +08:00
|
|
|
*
|
2012-12-05 11:18:42 +08:00
|
|
|
* Returns: the current vector object, 0 if no vector exists in the
|
|
|
|
* image.
|
2005-12-30 04:55:07 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-30 04:55:07 +08:00
|
|
|
gint32
|
|
|
|
gimp_vectors_new (gint32 image_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
const gchar *name)
|
2005-12-30 04:55:07 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gint32 vectors_ID = -1;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-new",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_STRING, name,
|
|
|
|
GIMP_PDB_END);
|
2005-12-30 04:55:07 +08:00
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
vectors_ID = return_vals[1].data.d_vectors;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return vectors_ID;
|
|
|
|
}
|
|
|
|
|
2008-04-04 22:50:42 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_new_from_text_layer:
|
|
|
|
* @image_ID: The image.
|
|
|
|
* @layer_ID: The text layer.
|
|
|
|
*
|
|
|
|
* Creates a new vectors object from a text layer.
|
|
|
|
*
|
|
|
|
* Creates a new vectors object from a text layer. The vectors object
|
2010-09-06 06:03:29 +08:00
|
|
|
* needs to be added to the image using gimp_image_insert_vectors().
|
2008-04-04 22:50:42 +08:00
|
|
|
*
|
|
|
|
* Returns: The vectors of the text layer.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.6
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2008-04-04 22:50:42 +08:00
|
|
|
gint32
|
|
|
|
gimp_vectors_new_from_text_layer (gint32 image_ID,
|
|
|
|
gint32 layer_ID)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gint32 vectors_ID = -1;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-new-from-text-layer",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_LAYER, layer_ID,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
vectors_ID = return_vals[1].data.d_vectors;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return vectors_ID;
|
|
|
|
}
|
|
|
|
|
2008-07-28 22:13:18 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_copy:
|
|
|
|
* @vectors_ID: The vectors object to copy.
|
|
|
|
*
|
|
|
|
* Copy a vectors object.
|
|
|
|
*
|
|
|
|
* This procedure copies the specified vectors object and returns the
|
|
|
|
* copy.
|
|
|
|
*
|
|
|
|
* Returns: The newly copied vectors object.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.6
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2008-07-28 22:13:18 +08:00
|
|
|
gint32
|
|
|
|
gimp_vectors_copy (gint32 vectors_ID)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gint32 vectors_copy_ID = -1;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-copy",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
vectors_copy_ID = return_vals[1].data.d_vectors;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return vectors_copy_ID;
|
|
|
|
}
|
|
|
|
|
2006-03-24 05:17:16 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_get_strokes:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @num_strokes: The number of strokes returned.
|
|
|
|
*
|
|
|
|
* List the strokes associated with the passed path.
|
|
|
|
*
|
|
|
|
* Returns an Array with the stroke-IDs associated with the passed
|
|
|
|
* path.
|
|
|
|
*
|
|
|
|
* Returns: List of the strokes belonging to the path.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-03-24 05:17:16 +08:00
|
|
|
gint *
|
|
|
|
gimp_vectors_get_strokes (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint *num_strokes)
|
2006-03-24 05:17:16 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gint *stroke_ids = NULL;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-get-strokes",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_END);
|
2006-03-24 05:17:16 +08:00
|
|
|
|
|
|
|
*num_strokes = 0;
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
|
|
|
*num_strokes = return_vals[1].data.d_int32;
|
|
|
|
stroke_ids = g_new (gint32, *num_strokes);
|
2006-04-12 18:34:30 +08:00
|
|
|
memcpy (stroke_ids,
|
|
|
|
return_vals[2].data.d_int32array,
|
|
|
|
*num_strokes * sizeof (gint32));
|
2006-03-24 05:17:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return stroke_ids;
|
|
|
|
}
|
|
|
|
|
2005-12-29 05:24:12 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_get_length:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
2006-10-24 16:30:55 +08:00
|
|
|
* @precision: The precision used for the approximation.
|
2005-12-29 05:24:12 +08:00
|
|
|
*
|
2006-03-15 05:35:50 +08:00
|
|
|
* Measure the length of the given stroke.
|
2005-12-29 05:24:12 +08:00
|
|
|
*
|
|
|
|
* Measure the length of the given stroke.
|
|
|
|
*
|
|
|
|
* Returns: The length (in pixels) of the given stroke.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-29 05:24:12 +08:00
|
|
|
gdouble
|
|
|
|
gimp_vectors_stroke_get_length (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
2006-10-24 16:30:55 +08:00
|
|
|
gdouble precision)
|
2005-12-29 05:24:12 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
2006-04-02 19:22:47 +08:00
|
|
|
gdouble length = 0.0;
|
2005-12-29 05:24:12 +08:00
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-length",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
2006-10-24 16:30:55 +08:00
|
|
|
GIMP_PDB_FLOAT, precision,
|
2006-04-12 18:27:31 +08:00
|
|
|
GIMP_PDB_END);
|
2005-12-29 05:24:12 +08:00
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
length = return_vals[1].data.d_float;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2005-12-30 04:55:07 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_get_point_at_dist:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @dist: The given distance.
|
2006-10-24 16:30:55 +08:00
|
|
|
* @precision: The precision used for the approximation.
|
|
|
|
* @x_point: The x position of the point.
|
2005-12-30 04:55:07 +08:00
|
|
|
* @y_point: The y position of the point.
|
|
|
|
* @slope: The slope (dy / dx) at the specified point.
|
|
|
|
* @valid: Indicator for the validity of the returned data.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2006-10-24 16:30:55 +08:00
|
|
|
* Returns: TRUE on success.
|
2005-12-30 04:55:07 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-10-24 16:30:55 +08:00
|
|
|
gboolean
|
2005-12-30 04:55:07 +08:00
|
|
|
gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
|
|
|
gdouble dist,
|
2006-10-24 16:30:55 +08:00
|
|
|
gdouble precision,
|
|
|
|
gdouble *x_point,
|
2006-04-12 18:27:31 +08:00
|
|
|
gdouble *y_point,
|
|
|
|
gdouble *slope,
|
|
|
|
gboolean *valid)
|
2005-12-30 04:55:07 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
2006-10-24 16:30:55 +08:00
|
|
|
gboolean success = TRUE;
|
2005-12-30 04:55:07 +08:00
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-point-at-dist",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_FLOAT, dist,
|
2006-10-24 16:30:55 +08:00
|
|
|
GIMP_PDB_FLOAT, precision,
|
2006-04-12 18:27:31 +08:00
|
|
|
GIMP_PDB_END);
|
2005-12-30 04:55:07 +08:00
|
|
|
|
2006-10-24 16:30:55 +08:00
|
|
|
*x_point = 0.0;
|
|
|
|
*y_point = 0.0;
|
|
|
|
*slope = 0.0;
|
|
|
|
*valid = FALSE;
|
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
if (success)
|
2005-12-30 04:55:07 +08:00
|
|
|
{
|
2006-10-24 16:30:55 +08:00
|
|
|
*x_point = return_vals[1].data.d_float;
|
2005-12-30 04:55:07 +08:00
|
|
|
*y_point = return_vals[2].data.d_float;
|
|
|
|
*slope = return_vals[3].data.d_float;
|
|
|
|
*valid = return_vals[4].data.d_int32;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2006-10-24 16:30:55 +08:00
|
|
|
return success;
|
2005-12-30 04:55:07 +08:00
|
|
|
}
|
|
|
|
|
2005-06-02 00:20:46 +08:00
|
|
|
/**
|
2006-10-24 22:23:29 +08:00
|
|
|
* gimp_vectors_remove_stroke:
|
2005-06-02 00:20:46 +08:00
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
*
|
2005-12-29 05:24:12 +08:00
|
|
|
* remove the stroke from a vectors object.
|
2005-06-02 00:20:46 +08:00
|
|
|
*
|
2005-12-29 05:24:12 +08:00
|
|
|
* Remove the stroke from a vectors object.
|
2005-06-02 00:20:46 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-06-02 00:20:46 +08:00
|
|
|
gboolean
|
2006-10-24 22:23:29 +08:00
|
|
|
gimp_vectors_remove_stroke (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id)
|
2005-06-02 00:20:46 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
2006-10-24 22:23:29 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-remove-stroke",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_END);
|
2005-06-02 00:20:46 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2005-12-30 04:55:07 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_close:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
*
|
|
|
|
* closes the specified stroke.
|
|
|
|
*
|
|
|
|
* Closes the specified stroke.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-30 04:55:07 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_stroke_close (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id)
|
2005-12-30 04:55:07 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-close",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_END);
|
2005-12-30 04:55:07 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2005-05-17 09:20:03 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_translate:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
2005-12-29 05:24:12 +08:00
|
|
|
* @off_x: Offset in x direction.
|
|
|
|
* @off_y: Offset in y direction.
|
2005-05-17 09:20:03 +08:00
|
|
|
*
|
2005-06-02 00:20:46 +08:00
|
|
|
* translate the given stroke.
|
2005-05-17 09:20:03 +08:00
|
|
|
*
|
2005-06-02 00:20:46 +08:00
|
|
|
* Translate the given stroke.
|
2005-05-17 09:20:03 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-05-17 09:20:03 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_stroke_translate (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
|
|
|
gint off_x,
|
|
|
|
gint off_y)
|
2005-05-17 09:20:03 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-translate",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_INT32, off_x,
|
|
|
|
GIMP_PDB_INT32, off_y,
|
|
|
|
GIMP_PDB_END);
|
2005-12-29 05:24:12 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_scale:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @scale_x: Scale factor in x direction.
|
|
|
|
* @scale_y: Scale factor in y direction.
|
|
|
|
*
|
|
|
|
* scales the given stroke.
|
|
|
|
*
|
|
|
|
* Scale the given stroke.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-29 05:24:12 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_stroke_scale (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
|
|
|
gdouble scale_x,
|
|
|
|
gdouble scale_y)
|
2005-12-29 05:24:12 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-scale",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_FLOAT, scale_x,
|
|
|
|
GIMP_PDB_FLOAT, scale_y,
|
|
|
|
GIMP_PDB_END);
|
2005-05-17 09:20:03 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
2005-06-02 00:20:46 +08:00
|
|
|
|
2006-11-20 23:34:30 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_rotate:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @center_x: X coordinate of the rotation center.
|
|
|
|
* @center_y: Y coordinate of the rotation center.
|
|
|
|
* @angle: angle to rotate about.
|
|
|
|
*
|
|
|
|
* rotates the given stroke.
|
|
|
|
*
|
|
|
|
* Rotates the given stroke around given center by angle (in degrees).
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-11-20 23:34:30 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_stroke_rotate (gint32 vectors_ID,
|
|
|
|
gint stroke_id,
|
|
|
|
gdouble center_x,
|
|
|
|
gdouble center_y,
|
|
|
|
gdouble angle)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-rotate",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_FLOAT, center_x,
|
|
|
|
GIMP_PDB_FLOAT, center_y,
|
|
|
|
GIMP_PDB_FLOAT, angle,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_flip:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @flip_type: Flip orientation, either vertical or horizontal.
|
|
|
|
* @axis: axis coordinate about which to flip, in pixels.
|
|
|
|
*
|
|
|
|
* flips the given stroke.
|
|
|
|
*
|
|
|
|
* Rotates the given stroke around given center by angle (in degrees).
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-11-20 23:34:30 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_stroke_flip (gint32 vectors_ID,
|
|
|
|
gint stroke_id,
|
|
|
|
GimpOrientationType flip_type,
|
|
|
|
gdouble axis)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-flip",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_INT32, flip_type,
|
|
|
|
GIMP_PDB_FLOAT, axis,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_flip_free:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @x1: X coordinate of the first point of the flipping axis.
|
|
|
|
* @y1: Y coordinate of the first point of the flipping axis.
|
|
|
|
* @x2: X coordinate of the second point of the flipping axis.
|
|
|
|
* @y2: Y coordinate of the second point of the flipping axis.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-11-20 23:34:30 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_stroke_flip_free (gint32 vectors_ID,
|
|
|
|
gint stroke_id,
|
|
|
|
gdouble x1,
|
|
|
|
gdouble y1,
|
|
|
|
gdouble x2,
|
|
|
|
gdouble y2)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-flip-free",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_FLOAT, x1,
|
|
|
|
GIMP_PDB_FLOAT, y1,
|
|
|
|
GIMP_PDB_FLOAT, x2,
|
|
|
|
GIMP_PDB_FLOAT, y2,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2006-10-24 22:23:29 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_get_points:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @num_points: The number of floats returned.
|
|
|
|
* @controlpoints: List of the control points for the stroke (x0, y0, x1, y1, ...).
|
|
|
|
* @closed: Whether the stroke is closed or not.
|
|
|
|
*
|
|
|
|
* 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 Gimp 2.4
|
|
|
|
* this is always a bezier stroke, where the coordinates are the
|
|
|
|
* control points.
|
|
|
|
*
|
2012-12-05 11:18:42 +08:00
|
|
|
* Returns: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER
|
|
|
|
* for now).
|
2006-10-24 22:23:29 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-10-26 23:36:45 +08:00
|
|
|
GimpVectorsStrokeType
|
|
|
|
gimp_vectors_stroke_get_points (gint32 vectors_ID,
|
|
|
|
gint stroke_id,
|
|
|
|
gint *num_points,
|
|
|
|
gdouble **controlpoints,
|
|
|
|
gboolean *closed)
|
2006-10-24 22:23:29 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
2006-10-26 23:36:45 +08:00
|
|
|
GimpVectorsStrokeType type = 0;
|
2006-10-24 22:23:29 +08:00
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-get-points",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
*num_points = 0;
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
|
|
|
type = return_vals[1].data.d_int32;
|
|
|
|
*num_points = return_vals[2].data.d_int32;
|
|
|
|
*controlpoints = g_new (gdouble, *num_points);
|
|
|
|
memcpy (*controlpoints,
|
|
|
|
return_vals[3].data.d_floatarray,
|
|
|
|
*num_points * sizeof (gdouble));
|
|
|
|
*closed = return_vals[4].data.d_int32;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2006-10-26 23:36:45 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_new_from_points:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @type: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now).
|
|
|
|
* @num_points: The number of elements in the array, i.e. the number of controlpoints in the stroke * 2 (x- and y-coordinate).
|
|
|
|
* @controlpoints: List of the x- and y-coordinates of the control points.
|
|
|
|
* @closed: Whether the stroke is to be closed or not.
|
|
|
|
*
|
|
|
|
* 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 GIMP_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...
|
|
|
|
*
|
|
|
|
* Returns: The stroke ID of the newly created stroke.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-10-26 23:36:45 +08:00
|
|
|
gint
|
|
|
|
gimp_vectors_stroke_new_from_points (gint32 vectors_ID,
|
|
|
|
GimpVectorsStrokeType type,
|
|
|
|
gint num_points,
|
|
|
|
const gdouble *controlpoints,
|
|
|
|
gboolean closed)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gint stroke_id = 0;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-new-from-points",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, type,
|
|
|
|
GIMP_PDB_INT32, num_points,
|
|
|
|
GIMP_PDB_FLOATARRAY, controlpoints,
|
|
|
|
GIMP_PDB_INT32, closed,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
stroke_id = return_vals[1].data.d_int32;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return stroke_id;
|
|
|
|
}
|
|
|
|
|
2005-06-02 00:20:46 +08:00
|
|
|
/**
|
|
|
|
* gimp_vectors_stroke_interpolate:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
2006-10-24 16:30:55 +08:00
|
|
|
* @precision: The precision used for the approximation.
|
2005-06-02 00:20:46 +08:00
|
|
|
* @num_coords: The number of floats returned.
|
2006-10-24 16:30:55 +08:00
|
|
|
* @closed: Whether the stroke is closed or not.
|
2005-06-02 00:20:46 +08:00
|
|
|
*
|
|
|
|
* returns polygonal approximation of the stroke.
|
|
|
|
*
|
|
|
|
* returns polygonal approximation of the stroke.
|
|
|
|
*
|
2006-10-24 16:30:55 +08:00
|
|
|
* Returns: List of the coords along the path (x0, y0, x1, y1, ...).
|
2005-06-02 00:20:46 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-10-24 16:30:55 +08:00
|
|
|
gdouble *
|
2005-06-02 00:20:46 +08:00
|
|
|
gimp_vectors_stroke_interpolate (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
2006-10-24 16:30:55 +08:00
|
|
|
gdouble precision,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint *num_coords,
|
2006-10-24 16:30:55 +08:00
|
|
|
gboolean *closed)
|
2005-06-02 00:20:46 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
2006-10-24 16:30:55 +08:00
|
|
|
gdouble *coords = NULL;
|
2005-06-02 00:20:46 +08:00
|
|
|
|
2005-08-03 06:52:23 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-stroke-interpolate",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
2006-10-24 16:30:55 +08:00
|
|
|
GIMP_PDB_FLOAT, precision,
|
2006-04-12 18:27:31 +08:00
|
|
|
GIMP_PDB_END);
|
2005-06-02 00:20:46 +08:00
|
|
|
|
|
|
|
*num_coords = 0;
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
{
|
2006-10-24 16:30:55 +08:00
|
|
|
*num_coords = return_vals[1].data.d_int32;
|
|
|
|
coords = g_new (gdouble, *num_coords);
|
|
|
|
memcpy (coords,
|
|
|
|
return_vals[2].data.d_floatarray,
|
2006-04-12 18:34:30 +08:00
|
|
|
*num_coords * sizeof (gdouble));
|
2006-10-24 16:30:55 +08:00
|
|
|
*closed = return_vals[3].data.d_int32;
|
2005-06-02 00:20:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2006-10-24 16:30:55 +08:00
|
|
|
return coords;
|
2005-06-02 00:20:46 +08:00
|
|
|
}
|
2005-12-30 00:05:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_bezier_stroke_new_moveto:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @x0: The x-coordinate of the moveto.
|
|
|
|
* @y0: The y-coordinate of the moveto.
|
|
|
|
*
|
|
|
|
* Adds a bezier stroke with a single moveto to the vectors object.
|
|
|
|
*
|
|
|
|
* Adds a bezier stroke with a single moveto to the vectors object.
|
|
|
|
*
|
|
|
|
* Returns: The resulting stroke.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-30 00:05:31 +08:00
|
|
|
gint
|
|
|
|
gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gdouble x0,
|
|
|
|
gdouble y0)
|
2005-12-30 00:05:31 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gint stroke_id = 0;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-new-moveto",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_FLOAT, x0,
|
|
|
|
GIMP_PDB_FLOAT, y0,
|
|
|
|
GIMP_PDB_END);
|
2005-12-30 00:05:31 +08:00
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
stroke_id = return_vals[1].data.d_int32;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return stroke_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_bezier_stroke_lineto:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @x0: The x-coordinate of the lineto.
|
|
|
|
* @y0: The y-coordinate of the lineto.
|
|
|
|
*
|
|
|
|
* Extends a bezier stroke with a lineto.
|
|
|
|
*
|
|
|
|
* Extends a bezier stroke with a lineto.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-30 00:05:31 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
|
|
|
gdouble x0,
|
|
|
|
gdouble y0)
|
2005-12-30 00:05:31 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-lineto",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_FLOAT, x0,
|
|
|
|
GIMP_PDB_FLOAT, y0,
|
|
|
|
GIMP_PDB_END);
|
2005-12-30 00:05:31 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_bezier_stroke_conicto:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @x0: The x-coordinate of the control point.
|
|
|
|
* @y0: The y-coordinate of the control point.
|
|
|
|
* @x1: The x-coordinate of the end point.
|
|
|
|
* @y1: The y-coordinate of the end point.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-30 00:05:31 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
|
|
|
gdouble x0,
|
|
|
|
gdouble y0,
|
|
|
|
gdouble x1,
|
|
|
|
gdouble y1)
|
2005-12-30 00:05:31 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-conicto",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_FLOAT, x0,
|
|
|
|
GIMP_PDB_FLOAT, y0,
|
|
|
|
GIMP_PDB_FLOAT, x1,
|
|
|
|
GIMP_PDB_FLOAT, y1,
|
|
|
|
GIMP_PDB_END);
|
2005-12-30 00:05:31 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_bezier_stroke_cubicto:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @stroke_id: The stroke ID.
|
|
|
|
* @x0: The x-coordinate of the first control point.
|
|
|
|
* @y0: The y-coordinate of the first control point.
|
|
|
|
* @x1: The x-coordinate of the second control point.
|
|
|
|
* @y1: The y-coordinate of the second control point.
|
|
|
|
* @x2: The x-coordinate of the end point.
|
|
|
|
* @y2: The y-coordinate of the end point.
|
|
|
|
*
|
|
|
|
* Extends a bezier stroke with a cubic bezier spline.
|
|
|
|
*
|
|
|
|
* Extends a bezier stroke with a cubic bezier spline.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-30 00:05:31 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gint stroke_id,
|
|
|
|
gdouble x0,
|
|
|
|
gdouble y0,
|
|
|
|
gdouble x1,
|
|
|
|
gdouble y1,
|
|
|
|
gdouble x2,
|
|
|
|
gdouble y2)
|
2005-12-30 00:05:31 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-cubicto",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_INT32, stroke_id,
|
|
|
|
GIMP_PDB_FLOAT, x0,
|
|
|
|
GIMP_PDB_FLOAT, y0,
|
|
|
|
GIMP_PDB_FLOAT, x1,
|
|
|
|
GIMP_PDB_FLOAT, y1,
|
|
|
|
GIMP_PDB_FLOAT, x2,
|
|
|
|
GIMP_PDB_FLOAT, y2,
|
|
|
|
GIMP_PDB_END);
|
2005-12-30 00:05:31 +08:00
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_bezier_stroke_new_ellipse:
|
|
|
|
* @vectors_ID: The vectors object.
|
|
|
|
* @x0: The x-coordinate of the center.
|
|
|
|
* @y0: The y-coordinate of the center.
|
|
|
|
* @radius_x: The radius in x direction.
|
|
|
|
* @radius_y: The radius in y direction.
|
|
|
|
* @angle: The angle the x-axis of the ellipse (radians, counterclockwise).
|
|
|
|
*
|
|
|
|
* Adds a bezier stroke describing an ellipse the vectors object.
|
|
|
|
*
|
|
|
|
* Adds a bezier stroke describing an ellipse the vectors object.
|
|
|
|
*
|
|
|
|
* Returns: The resulting stroke.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2005-12-30 00:05:31 +08:00
|
|
|
gint
|
|
|
|
gimp_vectors_bezier_stroke_new_ellipse (gint32 vectors_ID,
|
2006-04-12 18:27:31 +08:00
|
|
|
gdouble x0,
|
|
|
|
gdouble y0,
|
|
|
|
gdouble radius_x,
|
|
|
|
gdouble radius_y,
|
|
|
|
gdouble angle)
|
2005-12-30 00:05:31 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gint stroke_id = 0;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-bezier-stroke-new-ellipse",
|
2006-04-12 18:27:31 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_FLOAT, x0,
|
|
|
|
GIMP_PDB_FLOAT, y0,
|
|
|
|
GIMP_PDB_FLOAT, radius_x,
|
|
|
|
GIMP_PDB_FLOAT, radius_y,
|
|
|
|
GIMP_PDB_FLOAT, angle,
|
|
|
|
GIMP_PDB_END);
|
2005-12-30 00:05:31 +08:00
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
stroke_id = return_vals[1].data.d_int32;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return stroke_id;
|
|
|
|
}
|
2006-07-28 22:54:31 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_to_selection:
|
|
|
|
* @vectors_ID: The vectors object to render to the selection.
|
2006-07-29 01:34:50 +08:00
|
|
|
* @operation: The desired operation with current selection.
|
2006-07-28 22:54:31 +08:00
|
|
|
* @antialias: Antialias selection.
|
|
|
|
* @feather: Feather selection.
|
|
|
|
* @feather_radius_x: Feather radius x.
|
|
|
|
* @feather_radius_y: Feather radius y.
|
|
|
|
*
|
2011-02-14 01:31:14 +08:00
|
|
|
* Deprecated: Use gimp_image_select_item() instead.
|
2006-07-28 22:54:31 +08:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-07-28 22:54:31 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_to_selection (gint32 vectors_ID,
|
2006-07-29 01:34:50 +08:00
|
|
|
GimpChannelOps operation,
|
2006-07-28 22:54:31 +08:00
|
|
|
gboolean antialias,
|
|
|
|
gboolean feather,
|
|
|
|
gdouble feather_radius_x,
|
|
|
|
gdouble feather_radius_y)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-to-selection",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
2006-07-29 01:34:50 +08:00
|
|
|
GIMP_PDB_INT32, operation,
|
2006-07-28 22:54:31 +08:00
|
|
|
GIMP_PDB_INT32, antialias,
|
|
|
|
GIMP_PDB_INT32, feather,
|
|
|
|
GIMP_PDB_FLOAT, feather_radius_x,
|
|
|
|
GIMP_PDB_FLOAT, feather_radius_y,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
2006-10-25 23:14:03 +08:00
|
|
|
|
|
|
|
/**
|
2006-11-24 05:45:54 +08:00
|
|
|
* gimp_vectors_import_from_file:
|
2006-10-25 23:14:03 +08:00
|
|
|
* @image_ID: The image.
|
|
|
|
* @filename: The name of the SVG file to import.
|
|
|
|
* @merge: Merge paths into a single vectors object.
|
|
|
|
* @scale: Scale the SVG to image dimensions.
|
|
|
|
* @num_vectors: The number of newly created vectors.
|
2006-10-31 07:04:12 +08:00
|
|
|
* @vectors_ids: The list of newly created vectors.
|
2006-10-25 23:14:03 +08:00
|
|
|
*
|
|
|
|
* Import paths from an SVG file.
|
|
|
|
*
|
|
|
|
* This procedure imports paths from an SVG file. SVG elements other
|
|
|
|
* than paths and basic shapes are ignored.
|
|
|
|
*
|
2006-10-31 07:04:12 +08:00
|
|
|
* Returns: TRUE on success.
|
2006-10-25 23:14:03 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-10-31 07:04:12 +08:00
|
|
|
gboolean
|
2006-11-24 05:45:54 +08:00
|
|
|
gimp_vectors_import_from_file (gint32 image_ID,
|
|
|
|
const gchar *filename,
|
|
|
|
gboolean merge,
|
|
|
|
gboolean scale,
|
|
|
|
gint *num_vectors,
|
|
|
|
gint32 **vectors_ids)
|
2006-10-25 23:14:03 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
2006-10-31 07:04:12 +08:00
|
|
|
gboolean success = TRUE;
|
2006-10-25 23:14:03 +08:00
|
|
|
|
2006-11-24 05:45:54 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-import-from-file",
|
2006-10-25 23:14:03 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_STRING, filename,
|
|
|
|
GIMP_PDB_INT32, merge,
|
|
|
|
GIMP_PDB_INT32, scale,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
*num_vectors = 0;
|
2006-10-31 07:04:12 +08:00
|
|
|
*vectors_ids = NULL;
|
2006-10-25 23:14:03 +08:00
|
|
|
|
2006-10-31 07:04:12 +08:00
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
if (success)
|
2006-10-25 23:14:03 +08:00
|
|
|
{
|
|
|
|
*num_vectors = return_vals[1].data.d_int32;
|
2006-10-31 07:04:12 +08:00
|
|
|
*vectors_ids = g_new (gint32, *num_vectors);
|
|
|
|
memcpy (*vectors_ids,
|
2006-10-25 23:14:03 +08:00
|
|
|
return_vals[2].data.d_int32array,
|
|
|
|
*num_vectors * sizeof (gint32));
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2006-10-31 07:04:12 +08:00
|
|
|
return success;
|
2006-10-25 23:14:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-11-24 05:45:54 +08:00
|
|
|
* gimp_vectors_import_from_string:
|
2006-10-25 23:14:03 +08:00
|
|
|
* @image_ID: The image.
|
|
|
|
* @string: A string that must be a complete and valid SVG document.
|
|
|
|
* @length: Number of bytes in string or -1 if the string is NULL terminated.
|
|
|
|
* @merge: Merge paths into a single vectors object.
|
|
|
|
* @scale: Scale the SVG to image dimensions.
|
|
|
|
* @num_vectors: The number of newly created vectors.
|
2006-10-31 07:04:12 +08:00
|
|
|
* @vectors_ids: The list of newly created vectors.
|
2006-10-25 23:14:03 +08:00
|
|
|
*
|
|
|
|
* Import paths from an SVG string.
|
|
|
|
*
|
2006-11-24 06:26:58 +08:00
|
|
|
* This procedure works like gimp_vectors_import_from_file() but takes
|
|
|
|
* a string rather than reading the SVG from a file. This allows you to
|
2006-10-25 23:14:03 +08:00
|
|
|
* write scripts that generate SVG and feed it to GIMP.
|
|
|
|
*
|
2006-10-31 07:04:12 +08:00
|
|
|
* Returns: TRUE on success.
|
2006-10-25 23:14:03 +08:00
|
|
|
*
|
|
|
|
* Since: GIMP 2.4
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2006-10-31 07:04:12 +08:00
|
|
|
gboolean
|
2006-11-24 05:45:54 +08:00
|
|
|
gimp_vectors_import_from_string (gint32 image_ID,
|
|
|
|
const gchar *string,
|
|
|
|
gint length,
|
|
|
|
gboolean merge,
|
|
|
|
gboolean scale,
|
|
|
|
gint *num_vectors,
|
|
|
|
gint32 **vectors_ids)
|
2006-10-25 23:14:03 +08:00
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
2006-10-31 07:04:12 +08:00
|
|
|
gboolean success = TRUE;
|
2006-10-25 23:14:03 +08:00
|
|
|
|
2006-11-24 05:45:54 +08:00
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-import-from-string",
|
2006-10-25 23:14:03 +08:00
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_STRING, string,
|
|
|
|
GIMP_PDB_INT32, length,
|
|
|
|
GIMP_PDB_INT32, merge,
|
|
|
|
GIMP_PDB_INT32, scale,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
*num_vectors = 0;
|
2006-10-31 07:04:12 +08:00
|
|
|
*vectors_ids = NULL;
|
2006-10-25 23:14:03 +08:00
|
|
|
|
2006-10-31 07:04:12 +08:00
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
if (success)
|
2006-10-25 23:14:03 +08:00
|
|
|
{
|
|
|
|
*num_vectors = return_vals[1].data.d_int32;
|
2006-10-31 07:04:12 +08:00
|
|
|
*vectors_ids = g_new (gint32, *num_vectors);
|
|
|
|
memcpy (*vectors_ids,
|
2006-10-25 23:14:03 +08:00
|
|
|
return_vals[2].data.d_int32array,
|
|
|
|
*num_vectors * sizeof (gint32));
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
2006-10-31 07:04:12 +08:00
|
|
|
return success;
|
2006-10-25 23:14:03 +08:00
|
|
|
}
|
2007-11-19 02:51:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_export_to_file:
|
|
|
|
* @image_ID: The image.
|
|
|
|
* @filename: The name of the SVG file to create.
|
|
|
|
* @vectors_ID: The vectors object to be saved, or 0 for all in the image.
|
|
|
|
*
|
|
|
|
* 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 GIMP. If you pass 0 as the
|
|
|
|
* 'vectors' argument, then all paths in the image will be exported.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.6
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2007-11-19 02:51:54 +08:00
|
|
|
gboolean
|
|
|
|
gimp_vectors_export_to_file (gint32 image_ID,
|
|
|
|
const gchar *filename,
|
|
|
|
gint32 vectors_ID)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-export-to-file",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_STRING, filename,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_vectors_export_to_string:
|
|
|
|
* @image_ID: The image.
|
|
|
|
* @vectors_ID: The vectors object to save, or 0 for all in the image.
|
|
|
|
*
|
|
|
|
* Save a path as an SVG string.
|
|
|
|
*
|
|
|
|
* This procedure works like gimp_vectors_export_to_file() but creates
|
2010-07-07 17:43:10 +08:00
|
|
|
* a string rather than a file. The contents are a NUL-terminated
|
2007-11-19 02:51:54 +08:00
|
|
|
* string that holds a complete XML document. If you pass 0 as the
|
|
|
|
* 'vectors' argument, then all paths in the image will be exported.
|
|
|
|
*
|
|
|
|
* Returns: A string whose contents are a complete SVG document.
|
|
|
|
*
|
|
|
|
* Since: GIMP 2.6
|
2010-09-16 04:07:36 +08:00
|
|
|
**/
|
2007-11-19 02:51:54 +08:00
|
|
|
gchar *
|
|
|
|
gimp_vectors_export_to_string (gint32 image_ID,
|
|
|
|
gint32 vectors_ID)
|
|
|
|
{
|
|
|
|
GimpParam *return_vals;
|
|
|
|
gint nreturn_vals;
|
|
|
|
gchar *string = NULL;
|
|
|
|
|
|
|
|
return_vals = gimp_run_procedure ("gimp-vectors-export-to-string",
|
|
|
|
&nreturn_vals,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_VECTORS, vectors_ID,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
|
|
|
|
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
|
|
|
string = g_strdup (return_vals[1].data.d_string);
|
|
|
|
|
|
|
|
gimp_destroy_params (return_vals, nreturn_vals);
|
|
|
|
|
|
|
|
return string;
|
|
|
|
}
|