Class: Gegl::Path

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instructions) ⇒ Gegl::Path

Creates a new Gegl::Path with the nodes described in the string instructions. See gegl_path_parse_string() for details of the format of the string.

Returns the newly created Gegl::Path

Parameters:

  • instructions (String)

    a string describing the path.

Class Method Details

.add_flattener(func) ⇒ nil

Add a new flattener, the flattener should produce a type of path that GeglPath already understands, if the flattener is unable to flatten the incoming path (doesn't understand the instructions), the original path should be returned.

Parameters:

  • func (Gegl::FlattenerFunc)

    a Gegl::FlattenerFunc

Returns:

  • (nil)

.add_type(type, items, description) ⇒ nil

Adds a new type to the path system, FIXME this should probably return something on registration conflicts, for now it expects all registered paths to be aware of each other.

Parameters:

  • type (Gegl::gchar)

    a gchar to recognize in path descriptions.

  • items (Integer)

    the number of floating point data items the instruction takes

  • description (String)

    a human readable description of this entry

Returns:

  • (nil)

Instance Method Details

#append(array) ⇒ nil

Use as follows: gegl_path_append (path, 'M', 0.0, 0.0); and gegl_path_append (path, 'C', 10.0, 10.0, 50.0, 10.0, 60.0, 0.0) the number of arguments are determined from the instruction provided.

Parameters:

  • array (Array)

    first instruction.

Returns:

  • (nil)

#calc(pos, x, y) ⇒ Boolean

Compute the coordinates of the path at the position (length measured from start of path, not including discontinuities).

Parameters:

  • pos (Float)

    how far along the path.

  • x (Float)

    return location for x coordinate.

  • y (Float)

    return location for y coordinate

Returns:

  • (Boolean)

#calc_values(num_samples, xs, ys) ⇒ nil

Compute num_samples for a path into the provided arrays xs and ys the returned values include the start and end positions of the path.

Parameters:

  • num_samples (Integer)

    number of samples to compute

  • xs (Array<Float>)

    return location for x coordinates

  • ys (Array<Float>)

    return location for y coordinates

Returns:

  • (nil)

#calc_y_for_x(x, y) ⇒ Integer

Compute a corresponding y coordinate for a given x input coordinate, returns 0 if computed correctly and -1 if the path doesn't exist for the specified x coordinate.

Parameters:

  • x (Float)

    x coordinate to compute for

  • y (Float)

    return location for y coordinate

Returns:

  • (Integer)

#clearnil

Remove all nods from a path.

Returns:

  • (nil)

#closest_point(x, y, on_path_x, on_path_y, node_pos_before) ⇒ Float

Figure out what and where on a path is closest to arbitrary coordinates.

Returns the length along the path where the closest point was encountered. was deemed the closest coordinate.

Parameters:

  • x (Float)

    x coordinate.

  • y (Float)

    y coordinate

  • on_path_x (Float)

    return location for x coordinate on the path that was closest

  • on_path_y (Float)

    return location for y coordinate on the path that was closest

  • node_pos_before (Integer)

    the node position interpreted before this position

Returns:

  • (Float)

#dirtynil

Marks the path as dirty and issues an invalidation for the path rendering, use this if modifying the values of a GeglPathPoint inline.

Returns:

  • (nil)

#flat_pathGegl::PathList

Return a polyline version of path

Returns:

  • (Gegl::PathList)

#foreach(each_item, user_data) ⇒ nil

Execute a provided function for every node in the path (useful for drawing and otherwise traversing a path.)

Parameters:

  • each_item (Gegl::NodeFunction)

    a function to call for each node in the path.

  • user_data (GObject)

    user data to pass to the function (in addition to the GeglPathItem).

Returns:

  • (nil)

#foreach_flat(each_item, user_data) ⇒ nil

Execute a provided function for the segments of a poly line approximating the path.

Parameters:

  • each_item (Gegl::NodeFunction)

    a function to call for each node in the path.

  • user_data (GObject)

    user data to pass to a node.

Returns:

  • (nil)

#freezenil

Make the GeglPath stop firing signals as it changes must be paired with a gegl_path_thaw() for the signals to start again.

Returns:

  • (nil)

#get_bounds(min_x, max_x, min_y, max_y) ⇒ nil

Compute the bounding box of a path.

Parameters:

  • min_x (Float)

    return location for minimum x coordinate

  • max_x (Float)

    return location for maximum x coordinate

  • min_y (Float)

    return location for minimum y coordinate

  • max_y (Float)

    return location for maximum y coordinate

Returns:

  • (nil)

#get_matrix(matrix) ⇒ nil

Get the transformation matrix of the path.

Parameters:

  • matrix (Gegl::Matrix3)

    a Gegl::Matrix3 to copy the matrix into

Returns:

  • (nil)

#get_node(index, node) ⇒ Boolean

Retrieve the node of the path at position pos.

Returns TRUE if the node was successfully retrieved.

Parameters:

  • index (Integer)

    the node number to retrieve

  • node (Gegl::PathItem)

    a pointer to a Gegl::PathItem record to be written.

Returns:

  • (Boolean)

#insert_node(pos, node) ⇒ nil

Insert the new node node at position pos in path. if pos = -1, the node is added in the last position.

Parameters:

  • pos (Integer)

    the position we want the new node to have.

  • node (Gegl::PathItem)

    pointer to a structure describing the GeglPathItem we want to store

Returns:

  • (nil)

#is_emptyBoolean

Check if the path contains any nodes.

Returns TRUE if the path has no nodes.

Returns:

  • (Boolean)

#lengthFloat

Returns the total length of the path.

Returns:

  • (Float)

    the length of the path.

#matrix=(matrix) ⇒ nil

Set the transformation matrix of the path.

The path is transformed through this matrix when being evaluated, causing the calculated positions and length to be changed by the transform.

Parameters:

  • matrix (Gegl::Matrix3)

    a Gegl::Matrix3 to copy the matrix from

Returns:

  • (nil)

#n_nodesInteger

Retrieves the number of nodes in the path.

Returns:

  • (Integer)

    the number of nodes in the path.

#parse_string(instructions) ⇒ nil

Parses instructions and appends corresponding nodes to path (call gegl_path_clean() first if you want to replace the existing path.

Parameters:

  • instructions (String)

    a string describing a path.

Returns:

  • (nil)

#pathGegl::PathList

Return the internal untouched Gegl::PathList

Returns:

  • (Gegl::PathList)

#remove_node(pos) ⇒ nil

Removes the node number pos in path.

Parameters:

  • pos (Integer)

    a node in the path.

Returns:

  • (nil)

#replace_node(pos, node) ⇒ nil

Replaces the exiting node at position pos in path.

Parameters:

  • pos (Integer)

    the position we want the new node to have.

  • node (Gegl::PathItem)

    pointer to a structure describing the GeglPathItem we want to store.

Returns:

  • (nil)

#thawnil

Restart firing signals (unless the path has been frozen multiple times).

Returns:

  • (nil)

#to_stringString

Serialize the paths nodes to a string. need to free this with g_free().

Returns:

  • (String)

    return a string with instructions describing the string you