Class: Clutter::Path

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

Overview

The Clutter::PathClass struct contains only private data.

Instance Method Summary collapse

Constructor Details

#initialize(desc) ⇒ Clutter::Path

Creates a new Clutter::Path instance with the nodes described in desc. See clutter_path_add_string() for details of the format of the string.

The object has a floating reference so if you add it to a Clutter::BehaviourPath then you do not need to unref it.

Parameters:

  • desc (String)

    a string describing the path

Instance Method Details

#add_cairo_path(cpath) ⇒ nil

Add the nodes of the Cairo path to the end of path.

Parameters:

  • cpath (cairo::Path)

    a Cairo path

Returns:

  • (nil)

#add_closenil

Adds a %CLUTTER_PATH_CLOSE type node to the path. This creates a straight line from the last node to the last %CLUTTER_PATH_MOVE_TO type node.

Returns:

  • (nil)

#add_curve_to(x_1, y_1, x_2, y_2, x_3, y_3) ⇒ nil

Adds a %CLUTTER_PATH_CURVE_TO type node to the path. This causes the actor to follow a bezier from the last node to (x_3, y_3) using (x_1, y_1) and (x_2,y_2) as control points.

Parameters:

  • x_1 (Integer)

    the x coordinate of the first control point

  • y_1 (Integer)

    the y coordinate of the first control point

  • x_2 (Integer)

    the x coordinate of the second control point

  • y_2 (Integer)

    the y coordinate of the second control point

  • x_3 (Integer)

    the x coordinate of the third control point

  • y_3 (Integer)

    the y coordinate of the third control point

Returns:

  • (nil)

#add_line_to(x, y) ⇒ nil

Adds a %CLUTTER_PATH_LINE_TO type node to the path. This causes the actor to move to the new coordinates in a straight line.

Parameters:

  • x (Integer)

    the x coordinate

  • y (Integer)

    the y coordinate

Returns:

  • (nil)

#add_move_to(x, y) ⇒ nil

Adds a %CLUTTER_PATH_MOVE_TO type node to the path. This is usually used as the first node in a path. It can also be used in the middle of the path to cause the actor to jump to the new coordinate.

Parameters:

  • x (Integer)

    the x coordinate

  • y (Integer)

    the y coordinate

Returns:

  • (nil)

#add_node(node) ⇒ nil

Adds node to the end of the path.

Parameters:

  • node (Clutter::PathNode)

    a Clutter::PathNode

Returns:

  • (nil)

#add_rel_curve_to(x_1, y_1, x_2, y_2, x_3, y_3) ⇒ nil

Same as clutter_path_add_curve_to() except the coordinates are relative to the previous node.

Parameters:

  • x_1 (Integer)

    the x coordinate of the first control point

  • y_1 (Integer)

    the y coordinate of the first control point

  • x_2 (Integer)

    the x coordinate of the second control point

  • y_2 (Integer)

    the y coordinate of the second control point

  • x_3 (Integer)

    the x coordinate of the third control point

  • y_3 (Integer)

    the y coordinate of the third control point

Returns:

  • (nil)

#add_rel_line_to(x, y) ⇒ nil

Same as clutter_path_add_line_to() except the coordinates are relative to the previous node.

Parameters:

  • x (Integer)

    the x coordinate

  • y (Integer)

    the y coordinate

Returns:

  • (nil)

#add_rel_move_to(x, y) ⇒ nil

Same as clutter_path_add_move_to() except the coordinates are relative to the previous node.

Parameters:

  • x (Integer)

    the x coordinate

  • y (Integer)

    the y coordinate

Returns:

  • (nil)

#add_string(str) ⇒ Boolean

Adds new nodes to the end of the path as described in str. The format is a subset of the SVG path format. Each node is represented by a letter and is followed by zero, one or three pairs of coordinates. The coordinates can be separated by spaces or a comma. The types are:

  • M: Adds a %CLUTTER_PATH_MOVE_TO node. Takes one pair of coordinates.
  • L: Adds a %CLUTTER_PATH_LINE_TO node. Takes one pair of coordinates.
  • C: Adds a %CLUTTER_PATH_CURVE_TO node. Takes three pairs of coordinates.
  • z: Adds a %CLUTTER_PATH_CLOSE node. No coordinates are needed.

The M, L and C commands can also be specified in lower case which means the coordinates are relative to the previous node.

For example, to move an actor in a 100 by 100 pixel square centered on the point 300,300 you could use the following path:

|[ M 250,350 l 0 -100 L 350,250 l 0 100 z ]|

If the path description isn't valid false will be returned and no nodes will be added. otherwise.

Parameters:

  • str (String)

    a string describing the new nodes

Returns:

  • (Boolean)

    true is the path description was valid or false

#clearnil

Removes all nodes from the path.

Returns:

  • (nil)

#descriptionString

Returns description.

Returns:

  • (String)

    description

#description=(description) ⇒ String

Parameters:

  • description (String)

Returns:

  • (String)

    description

  • (String)

    description

#foreach(callback, user_data) ⇒ nil

Calls a function for each node of the path.

Parameters:

  • callback (Clutter::PathCallback)

    the function to call with each node

  • user_data (GObject)

    user data to pass to the function

Returns:

  • (nil)

#get_node(index_, node) ⇒ nil

Retrieves the node of the path indexed by index.

Parameters:

  • index_ (Integer)

    the node number to retrieve

  • node (Clutter::PathNode)

    a location to store a copy of the node

Returns:

  • (nil)

#get_position(progress, position) ⇒ Integer

The value in progress represents a position along the path where 0.0 is the beginning and 1.0 is the end of the path. An interpolated position is then stored in position.

Parameters:

  • progress (Float)

    a position along the path as a fraction of its length

  • position (Clutter::Knot)

    location to store the position

Returns:

  • (Integer)

    index of the node used to calculate the position.

#insert_node(index_, node) ⇒ nil

Inserts node into the path before the node at the given offset. If index_ is negative it will append the node to the end of the path.

Parameters:

  • index_ (Integer)

    offset of where to insert the node

  • node (Clutter::PathNode)

    the node to insert

Returns:

  • (nil)

#lengthInteger

Returns length.

Returns:

  • (Integer)

    length

#length=(length) ⇒ Integer

Parameters:

  • length (Integer)

Returns:

  • (Integer)

    length

  • (Integer)

    length

#n_nodesInteger

Retrieves the number of nodes in the path.

Returns:

  • (Integer)

    the number of nodes.

#nodesGLib::SList<Clutter::PathNode>

Returns a #GSList of Clutter::PathNodes. The list should be freed with g_slist_free(). The nodes are owned by the path and should not be freed. Altering the path may cause the nodes in the list to become invalid so you should copy them if you want to keep the list.

Returns:

  • (GLib::SList<Clutter::PathNode>)

    a list of nodes in the path.

#remove_node(index_) ⇒ nil

Removes the node at the given offset from the path.

Parameters:

  • index_ (Integer)

    index of the node to remove

Returns:

  • (nil)

#replace_node(index_, node) ⇒ nil

Replaces the node at offset index_ with node.

Parameters:

  • index_ (Integer)

    index to the existing node

  • node (Clutter::PathNode)

    the replacement node

Returns:

  • (nil)

#to_cairo_path(cr) ⇒ nil

Add the nodes of the ClutterPath to the path in the Cairo context.

Parameters:

  • cr (cairo::Context)

    a Cairo context

Returns:

  • (nil)