Gimp.Path

g GObject.Object GObject.Object Gimp.Item Gimp.Item GObject.Object->Gimp.Item Gimp.Path Gimp.Path Gimp.Item->Gimp.Path

Subclasses:

None

Methods

Inherited:

Gimp.Item (55), GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

free (path)

class

get_by_id (path_id)

class

get_user_writable_dir (path)

class

new (image, name)

class

new_from_text_layer (image, layer)

class

parse (path, max_paths, check)

class

to_str (path)

bezier_stroke_conicto (stroke_id, x0, y0, x1, y1)

bezier_stroke_cubicto (stroke_id, x0, y0, x1, y1, x2, y2)

bezier_stroke_lineto (stroke_id, x0, y0)

bezier_stroke_new_ellipse (x0, y0, radius_x, radius_y, angle)

bezier_stroke_new_moveto (x0, y0)

copy ()

get_strokes ()

remove_stroke (stroke_id)

stroke_close (stroke_id)

stroke_flip (stroke_id, flip_type, axis)

stroke_flip_free (stroke_id, x1, y1, x2, y2)

stroke_get_length (stroke_id, precision)

stroke_get_point_at_dist (stroke_id, dist, precision)

stroke_get_points (stroke_id)

stroke_interpolate (stroke_id, precision)

stroke_new_from_points (type, controlpoints, closed)

stroke_reverse (stroke_id)

stroke_rotate (stroke_id, center_x, center_y, angle)

stroke_scale (stroke_id, scale_x, scale_y)

stroke_translate (stroke_id, off_x, off_y)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Inherited:

Gimp.Item (1)

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Gimp.Path(**kwargs)
Bases:

Gimp.Item

Abstract:

No

Structure:

Gimp.PathClass

Functions for querying and manipulating path.

classmethod free(path)
Parameters:

path ([str]) – A list of directories as returned by Gimp.Path.parse().

This function frees the memory allocated for the list and the strings it contains.

classmethod get_by_id(path_id)
Parameters:

path_id (int) – The path id.

Returns:

a Gimp.Path for path_id or None if path_id does not represent a valid path. The object belongs to libgimp and you must not modify or unref it.

Return type:

Gimp.Path or None

Returns a Gimp.Path representing path_id. This function calls Gimp.Item.get_by_id() and returns the item if it is a path or None otherwise.

New in version 3.0.

classmethod get_user_writable_dir(path)
Parameters:

path ([str]) – A list of directories as returned by Gimp.Path.parse().

Returns:

The first directory in path where the user has write permission.

Return type:

str

Note that you have to GLib.free() the returned string.

classmethod new(image, name)
Parameters:
  • image (Gimp.Image) – The image.

  • name (str) – the name of the new path object.

Returns:

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

Return type:

Gimp.Path

Creates a new empty path object.

Creates a new empty path object. The path object needs to be added to the image using Gimp.Image.insert_path().

New in version 2.4.

classmethod new_from_text_layer(image, layer)
Parameters:
Returns:

The path of the text layer.

Return type:

Gimp.Path

Creates a new path object from a text layer.

Creates a new path object from a text layer. The path object needs to be added to the image using Gimp.Image.insert_path().

New in version 2.6.

classmethod parse(path, max_paths, check)
Parameters:
  • path (str) – A list of directories separated by GLib.SEARCHPATH_SEPARATOR.

  • max_paths (int) – The maximum number of directories to return.

  • check (bool) – True if you want the directories to be checked.

Returns:

A GLib.List of all directories in path.

check_failed:

Returns a GLib.List of path elements for which the check failed.

Return type:

([str], check_failed: [str])

classmethod to_str(path)
Parameters:

path ([str]) – A list of directories as returned by Gimp.Path.parse().

Returns:

A searchpath string separated by GLib.SEARCHPATH_SEPARATOR.

Return type:

str

bezier_stroke_conicto(stroke_id, x0, y0, x1, y1)
Parameters:
  • stroke_id (int) – The stroke ID.

  • x0 (float) – The x-coordinate of the control point.

  • y0 (float) – The y-coordinate of the control point.

  • x1 (float) – The x-coordinate of the end point.

  • y1 (float) – The y-coordinate of the end point.

Returns:

True on success.

Return type:

bool

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.

New in version 2.4.

bezier_stroke_cubicto(stroke_id, x0, y0, x1, y1, x2, y2)
Parameters:
  • stroke_id (int) – The stroke ID.

  • x0 (float) – The x-coordinate of the first control point.

  • y0 (float) – The y-coordinate of the first control point.

  • x1 (float) – The x-coordinate of the second control point.

  • y1 (float) – The y-coordinate of the second control point.

  • x2 (float) – The x-coordinate of the end point.

  • y2 (float) – The y-coordinate of the end point.

Returns:

True on success.

Return type:

bool

Extends a bezier stroke with a cubic bezier spline.

Extends a bezier stroke with a cubic bezier spline.

New in version 2.4.

bezier_stroke_lineto(stroke_id, x0, y0)
Parameters:
  • stroke_id (int) – The stroke ID.

  • x0 (float) – The x-coordinate of the lineto.

  • y0 (float) – The y-coordinate of the lineto.

Returns:

True on success.

Return type:

bool

Extends a bezier stroke with a lineto.

Extends a bezier stroke with a lineto.

New in version 2.4.

bezier_stroke_new_ellipse(x0, y0, radius_x, radius_y, angle)
Parameters:
  • x0 (float) – The x-coordinate of the center.

  • y0 (float) – The y-coordinate of the center.

  • radius_x (float) – The radius in x direction.

  • radius_y (float) – The radius in y direction.

  • angle (float) – The angle the x-axis of the ellipse (radians, counterclockwise).

Returns:

The resulting stroke.

Return type:

int

Adds a bezier stroke describing an ellipse the path object.

Adds a bezier stroke describing an ellipse on the path object.

New in version 2.4.

bezier_stroke_new_moveto(x0, y0)
Parameters:
  • x0 (float) – The x-coordinate of the moveto.

  • y0 (float) – The y-coordinate of the moveto.

Returns:

The resulting stroke.

Return type:

int

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

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

New in version 2.4.

copy()
Returns:

The newly copied path object.

Return type:

Gimp.Path

Copy a path object.

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

New in version 2.6.

get_strokes()
Returns:

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

Return type:

[int]

List the strokes associated with the passed path.

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

New in version 2.4.

remove_stroke(stroke_id)
Parameters:

stroke_id (int) – The stroke ID.

Returns:

True on success.

Return type:

bool

remove the stroke from a path object.

Remove the stroke from a path object.

New in version 2.4.

stroke_close(stroke_id)
Parameters:

stroke_id (int) – The stroke ID.

Returns:

True on success.

Return type:

bool

closes the specified stroke.

Closes the specified stroke.

New in version 2.4.

stroke_flip(stroke_id, flip_type, axis)
Parameters:
  • stroke_id (int) – The stroke ID.

  • flip_type (Gimp.OrientationType) – Flip orientation, either vertical or horizontal.

  • axis (float) – axis coordinate about which to flip, in pixels.

Returns:

True on success.

Return type:

bool

flips the given stroke.

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

New in version 2.4.

stroke_flip_free(stroke_id, x1, y1, x2, y2)
Parameters:
  • stroke_id (int) – The stroke ID.

  • x1 (float) – X coordinate of the first point of the flipping axis.

  • y1 (float) – Y coordinate of the first point of the flipping axis.

  • x2 (float) – X coordinate of the second point of the flipping axis.

  • y2 (float) – Y coordinate of the second point of the flipping axis.

Returns:

True on success.

Return type:

bool

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.

New in version 2.4.

stroke_get_length(stroke_id, precision)
Parameters:
  • stroke_id (int) – The stroke ID.

  • precision (float) – The precision used for approximating straight portions of the stroke.

Returns:

The length (in pixels) of the given stroke.

Return type:

float

Measure the length of the given stroke.

Measure the length of the given stroke.

New in version 2.4.

stroke_get_point_at_dist(stroke_id, dist, precision)
Parameters:
  • stroke_id (int) – The stroke ID.

  • dist (float) – The given distance.

  • precision (float) – The precision used for the approximation.

Returns:

True on success.

x_point:

The x position of the point.

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.

Return type:

(bool, x_point: float, y_point: float, slope: float, valid: bool)

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.

New in version 2.4.

stroke_get_points(stroke_id)
Parameters:

stroke_id (int) – The stroke ID.

Returns:

type of the stroke (always Gimp.PathStrokeType.BEZIER for now).

controlpoints:

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

closed:

Whether the stroke is closed or not.

Return type:

(Gimp.PathStrokeType, controlpoints: [float], closed: bool)

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.

New in version 2.4.

stroke_interpolate(stroke_id, precision)
Parameters:
  • stroke_id (int) – The stroke ID.

  • precision (float) – The precision used for the approximation.

Returns:

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

closed:

Whether the stroke is closed or not.

Return type:

([float], closed: bool)

returns polygonal approximation of the stroke.

returns polygonal approximation of the stroke.

New in version 2.4.

stroke_new_from_points(type, controlpoints, closed)
Parameters:
Returns:

The stroke ID of the newly created stroke.

Return type:

int

Adds a stroke of a given type to the path object.

Adds a stroke of a given type to the path object. The coordinates of the control points can be specified. For now only strokes of the type Gimp.PathStrokeType.BEZIER are supported. The control points are specified as a pair of double 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…

New in version 2.4.

stroke_reverse(stroke_id)
Parameters:

stroke_id (int) – The stroke ID.

Returns:

True on success.

Return type:

bool

reverses the specified stroke.

Reverses the specified stroke.

New in version 3.0.

stroke_rotate(stroke_id, center_x, center_y, angle)
Parameters:
  • stroke_id (int) – The stroke ID.

  • center_x (float) – X coordinate of the rotation center.

  • center_y (float) – Y coordinate of the rotation center.

  • angle (float) – angle to rotate about.

Returns:

True on success.

Return type:

bool

rotates the given stroke.

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

New in version 2.4.

stroke_scale(stroke_id, scale_x, scale_y)
Parameters:
  • stroke_id (int) – The stroke ID.

  • scale_x (float) – Scale factor in x direction.

  • scale_y (float) – Scale factor in y direction.

Returns:

True on success.

Return type:

bool

scales the given stroke.

Scale the given stroke.

New in version 2.4.

stroke_translate(stroke_id, off_x, off_y)
Parameters:
  • stroke_id (int) – The stroke ID.

  • off_x (float) – Offset in x direction.

  • off_y (float) – Offset in y direction.

Returns:

True on success.

Return type:

bool

translate the given stroke.

Translate the given stroke.

New in version 2.4.