gimpvectors

gimpvectors — Functions for querying and manipulating vectors.

Functions

Object Hierarchy

    GObject
    ╰── GimpItem
        ╰── GimpVectors

Description

Functions for querying and manipulating vectors.

Functions

gimp_vectors_get_by_id ()

GimpVectors *
gimp_vectors_get_by_id (gint32 vectors_id);

Returns a GimpVectors representing vectors_id . This function calls gimp_item_get_by_id() and returns the item if it is vectors or NULL otherwise.

Parameters

vectors_id

The vectors id.

 

Returns

a GimpVectors for vectors_id or NULL if vectors_id does not represent a valid vectors. The object belongs to libgimp and you must not modify or unref it.

[nullable][transfer none]

Since: 3.0


gimp_vectors_new ()

GimpVectors *
gimp_vectors_new (GimpImage *image,
                  const gchar *name);

Creates a new empty vectors object.

Creates a new empty vectors object. The vectors object needs to be added to the image using gimp_image_insert_vectors().

Parameters

image

The image.

 

name

the name of the new vector object.

 

Returns

the current vector object, 0 if no vector exists in the image.

[transfer none]

Since: 2.4


gimp_vectors_new_from_text_layer ()

GimpVectors *
gimp_vectors_new_from_text_layer (GimpImage *image,
                                  GimpLayer *layer);

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 gimp_image_insert_vectors().

Parameters

image

The image.

 

layer

The text layer.

 

Returns

The vectors of the text layer.

[transfer none]

Since: 2.6


gimp_vectors_copy ()

GimpVectors *
gimp_vectors_copy (GimpVectors *vectors);

Copy a vectors object.

This procedure copies the specified vectors object and returns the copy.

Parameters

vectors

The vectors object to copy.

 

Returns

The newly copied vectors object.

[transfer none]

Since: 2.6


gimp_vectors_get_strokes ()

gint *
gimp_vectors_get_strokes (GimpVectors *vectors,
                          gint *num_strokes);

List the strokes associated with the passed path.

Returns an Array with the stroke-IDs associated with the passed path.

Parameters

vectors

The vectors object.

 

num_strokes

The number of strokes returned.

[out]

Returns

List of the strokes belonging to the path. The returned value must be freed with g_free().

[array length=num_strokes][element-type gint32][transfer full]

Since: 2.4


gimp_vectors_remove_stroke ()

gboolean
gimp_vectors_remove_stroke (GimpVectors *vectors,
                            gint stroke_id);

remove the stroke from a vectors object.

Remove the stroke from a vectors object.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_export_to_file ()

gboolean
gimp_vectors_export_to_file (GimpImage *image,
                             GFile *file,
                             GimpVectors *vectors);

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.

Parameters

image

The image.

 

file

The SVG file to create.

 

vectors

The vectors object to be saved, or 0 for all in the image.

 

Returns

TRUE on success.

Since: 2.6


gimp_vectors_export_to_string ()

gchar *
gimp_vectors_export_to_string (GimpImage *image,
                               GimpVectors *vectors);

Save a path as an SVG string.

This procedure works like gimp_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.

Parameters

image

The image.

 

vectors

The vectors object to save, or 0 for all in the image.

 

Returns

A string whose contents are a complete SVG document. The returned value must be freed with g_free().

[transfer full]

Since: 2.6


gimp_vectors_import_from_file ()

gboolean
gimp_vectors_import_from_file (GimpImage *image,
                               GFile *file,
                               gboolean merge,
                               gboolean scale,
                               gint *num_vectors,
                               GimpVectors ***vectors);

Import paths from an SVG file.

This procedure imports paths from an SVG file. SVG elements other than paths and basic shapes are ignored.

Parameters

image

The image.

 

file

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.

[out]

vectors

The list of newly created vectors.

[out][array length=num_vectors][element-type GimpVectors][transfer container]

Returns

TRUE on success.

Since: 2.4


gimp_vectors_import_from_string ()

gboolean
gimp_vectors_import_from_string (GimpImage *image,
                                 const gchar *string,
                                 gint length,
                                 gboolean merge,
                                 gboolean scale,
                                 gint *num_vectors,
                                 GimpVectors ***vectors);

Import paths from an SVG string.

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 write scripts that generate SVG and feed it to GIMP.

Parameters

image

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.

[out]

vectors

The list of newly created vectors.

[out][array length=num_vectors][element-type GimpVectors][transfer container]

Returns

TRUE on success.

Since: 2.4


gimp_vectors_stroke_new_from_points ()

gint
gimp_vectors_stroke_new_from_points (GimpVectors *vectors,
                                     GimpVectorsStrokeType type,
                                     gint num_points,
                                     const gdouble *controlpoints,
                                     gboolean closed);

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...

Parameters

vectors

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.

[array length=num_points][element-type gdouble]

closed

Whether the stroke is to be closed or not.

 

Returns

The stroke ID of the newly created stroke.

Since: 2.4


gimp_vectors_stroke_close ()

gboolean
gimp_vectors_stroke_close (GimpVectors *vectors,
                           gint stroke_id);

closes the specified stroke.

Closes the specified stroke.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_stroke_get_length ()

gdouble
gimp_vectors_stroke_get_length (GimpVectors *vectors,
                                gint stroke_id,
                                gdouble precision);

Measure the length of the given stroke.

Measure the length of the given stroke.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

precision

The precision used for the approximation.

 

Returns

The length (in pixels) of the given stroke.

Since: 2.4


gimp_vectors_stroke_get_points ()

GimpVectorsStrokeType
gimp_vectors_stroke_get_points (GimpVectors *vectors,
                                gint stroke_id,
                                gint *num_points,
                                gdouble **controlpoints,
                                gboolean *closed);

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.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

num_points

The number of floats returned.

[out]

controlpoints

List of the control points for the stroke (x0, y0, x1, y1, ...).

[out][array length=num_points][element-type gdouble][transfer full]

closed

Whether the stroke is closed or not.

[out]

Returns

type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now).

Since: 2.4


gimp_vectors_stroke_get_point_at_dist ()

gboolean
gimp_vectors_stroke_get_point_at_dist (GimpVectors *vectors,
                                       gint stroke_id,
                                       gdouble dist,
                                       gdouble precision,
                                       gdouble *x_point,
                                       gdouble *y_point,
                                       gdouble *slope,
                                       gboolean *valid);

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.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

dist

The given distance.

 

precision

The precision used for the approximation.

 

x_point

The x position of the point.

[out]

y_point

The y position of the point.

[out]

slope

The slope (dy / dx) at the specified point.

[out]

valid

Indicator for the validity of the returned data.

[out]

Returns

TRUE on success.

Since: 2.4


gimp_vectors_stroke_interpolate ()

gdouble *
gimp_vectors_stroke_interpolate (GimpVectors *vectors,
                                 gint stroke_id,
                                 gdouble precision,
                                 gint *num_coords,
                                 gboolean *closed);

returns polygonal approximation of the stroke.

returns polygonal approximation of the stroke.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

precision

The precision used for the approximation.

 

num_coords

The number of floats returned.

[out]

closed

Whether the stroke is closed or not.

[out]

Returns

List of the coords along the path (x0, y0, x1, y1, ...). The returned value must be freed with g_free().

[array length=num_coords][element-type gdouble][transfer full]

Since: 2.4


gimp_vectors_stroke_scale ()

gboolean
gimp_vectors_stroke_scale (GimpVectors *vectors,
                           gint stroke_id,
                           gdouble scale_x,
                           gdouble scale_y);

scales the given stroke.

Scale the given stroke.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

scale_x

Scale factor in x direction.

 

scale_y

Scale factor in y direction.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_stroke_translate ()

gboolean
gimp_vectors_stroke_translate (GimpVectors *vectors,
                               gint stroke_id,
                               gint off_x,
                               gint off_y);

translate the given stroke.

Translate the given stroke.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

off_x

Offset in x direction.

 

off_y

Offset in y direction.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_stroke_flip ()

gboolean
gimp_vectors_stroke_flip (GimpVectors *vectors,
                          gint stroke_id,
                          GimpOrientationType flip_type,
                          gdouble axis);

flips the given stroke.

Rotates the given stroke around given center by angle (in degrees).

Parameters

vectors

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.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_stroke_flip_free ()

gboolean
gimp_vectors_stroke_flip_free (GimpVectors *vectors,
                               gint stroke_id,
                               gdouble x1,
                               gdouble y1,
                               gdouble x2,
                               gdouble y2);

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.

Parameters

vectors

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.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_stroke_rotate ()

gboolean
gimp_vectors_stroke_rotate (GimpVectors *vectors,
                            gint stroke_id,
                            gdouble center_x,
                            gdouble center_y,
                            gdouble angle);

rotates the given stroke.

Rotates the given stroke around given center by angle (in degrees).

Parameters

vectors

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.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_bezier_stroke_conicto ()

gboolean
gimp_vectors_bezier_stroke_conicto (GimpVectors *vectors,
                                    gint stroke_id,
                                    gdouble x0,
                                    gdouble y0,
                                    gdouble x1,
                                    gdouble y1);

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.

Parameters

vectors

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.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_bezier_stroke_cubicto ()

gboolean
gimp_vectors_bezier_stroke_cubicto (GimpVectors *vectors,
                                    gint stroke_id,
                                    gdouble x0,
                                    gdouble y0,
                                    gdouble x1,
                                    gdouble y1,
                                    gdouble x2,
                                    gdouble y2);

Extends a bezier stroke with a cubic bezier spline.

Extends a bezier stroke with a cubic bezier spline.

Parameters

vectors

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.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_bezier_stroke_lineto ()

gboolean
gimp_vectors_bezier_stroke_lineto (GimpVectors *vectors,
                                   gint stroke_id,
                                   gdouble x0,
                                   gdouble y0);

Extends a bezier stroke with a lineto.

Extends a bezier stroke with a lineto.

Parameters

vectors

The vectors object.

 

stroke_id

The stroke ID.

 

x0

The x-coordinate of the lineto.

 

y0

The y-coordinate of the lineto.

 

Returns

TRUE on success.

Since: 2.4


gimp_vectors_bezier_stroke_new_ellipse ()

gint
gimp_vectors_bezier_stroke_new_ellipse
                               (GimpVectors *vectors,
                                gdouble x0,
                                gdouble y0,
                                gdouble radius_x,
                                gdouble radius_y,
                                gdouble angle);

Adds a bezier stroke describing an ellipse the vectors object.

Adds a bezier stroke describing an ellipse the vectors object.

Parameters

vectors

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).

 

Returns

The resulting stroke.

Since: 2.4


gimp_vectors_bezier_stroke_new_moveto ()

gint
gimp_vectors_bezier_stroke_new_moveto (GimpVectors *vectors,
                                       gdouble x0,
                                       gdouble y0);

Adds a bezier stroke with a single moveto to the vectors object.

Adds a bezier stroke with a single moveto to the vectors object.

Parameters

vectors

The vectors object.

 

x0

The x-coordinate of the moveto.

 

y0

The y-coordinate of the moveto.

 

Returns

The resulting stroke.

Since: 2.4