Clutter.Path

g Clutter.Path Clutter.Path GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Clutter.Path GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_with_description (desc)

add_cairo_path (cpath)

add_close ()

add_curve_to (x_1, y_1, x_2, y_2, x_3, y_3)

add_line_to (x, y)

add_move_to (x, y)

add_node (node)

add_rel_curve_to (x_1, y_1, x_2, y_2, x_3, y_3)

add_rel_line_to (x, y)

add_rel_move_to (x, y)

add_string (str)

clear ()

foreach (callback, *user_data)

get_description ()

get_length ()

get_n_nodes ()

get_node (index_)

get_nodes ()

get_position (progress)

insert_node (index_, node)

remove_node (index_)

replace_node (index_, node)

set_description (str)

to_cairo_path (cr)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

description

str

r/w

SVG-style description of the path

length

int

r

An approximation of the total length of the path.

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.InitiallyUnowned

r

Class Details

class Clutter.Path(**kwargs)
Bases:

GObject.InitiallyUnowned

Abstract:

No

Structure:

Clutter.PathClass

The Clutter.Path struct contains only private data and should be accessed with the functions below.

New in version 1.0.

classmethod new()
Returns:

the newly created Clutter.Path

Return type:

Clutter.Path

Creates a new Clutter.Path instance with no nodes.

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

New in version 1.0.

classmethod new_with_description(desc)
Parameters:

desc (str) – a string describing the path

Returns:

the newly created Clutter.Path

Return type:

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.

New in version 1.0.

add_cairo_path(cpath)
Parameters:

cpath (cairo.Path) – a Cairo path

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

New in version 1.0.

add_close()

Adds a Clutter.PathNodeType.CLOSE type node to the path. This creates a straight line from the last node to the last Clutter.PathNodeType.MOVE_TO type node.

New in version 1.0.

add_curve_to(x_1, y_1, x_2, y_2, x_3, y_3)
Parameters:
  • x_1 (int) – the x coordinate of the first control point

  • y_1 (int) – the y coordinate of the first control point

  • x_2 (int) – the x coordinate of the second control point

  • y_2 (int) – the y coordinate of the second control point

  • x_3 (int) – the x coordinate of the third control point

  • y_3 (int) – the y coordinate of the third control point

Adds a Clutter.PathNodeType.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.

New in version 1.0.

add_line_to(x, y)
Parameters:
  • x (int) – the x coordinate

  • y (int) – the y coordinate

Adds a Clutter.PathNodeType.LINE_TO type node to the path. This causes the actor to move to the new coordinates in a straight line.

New in version 1.0.

add_move_to(x, y)
Parameters:
  • x (int) – the x coordinate

  • y (int) – the y coordinate

Adds a Clutter.PathNodeType.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.

New in version 1.0.

add_node(node)
Parameters:

node (Clutter.PathNode) – a Clutter.PathNode

Adds node to the end of the path.

New in version 1.0.

add_rel_curve_to(x_1, y_1, x_2, y_2, x_3, y_3)
Parameters:
  • x_1 (int) – the x coordinate of the first control point

  • y_1 (int) – the y coordinate of the first control point

  • x_2 (int) – the x coordinate of the second control point

  • y_2 (int) – the y coordinate of the second control point

  • x_3 (int) – the x coordinate of the third control point

  • y_3 (int) – the y coordinate of the third control point

Same as Clutter.Path.add_curve_to() except the coordinates are relative to the previous node.

New in version 1.0.

add_rel_line_to(x, y)
Parameters:
  • x (int) – the x coordinate

  • y (int) – the y coordinate

Same as Clutter.Path.add_line_to() except the coordinates are relative to the previous node.

New in version 1.0.

add_rel_move_to(x, y)
Parameters:
  • x (int) – the x coordinate

  • y (int) – the y coordinate

Same as Clutter.Path.add_move_to() except the coordinates are relative to the previous node.

New in version 1.0.

add_string(str)
Parameters:

str (str) – a string describing the new nodes

Returns:

True is the path description was valid or False otherwise.

Return type:

bool

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:

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.

New in version 1.0.

clear()

Removes all nodes from the path.

New in version 1.0.

foreach(callback, *user_data)
Parameters:

Calls a function for each node of the path.

New in version 1.0.

get_description()
Returns:

a string description of the path. Free with GLib.free().

Return type:

str

Returns a newly allocated string describing the path in the same format as used by Clutter.Path.add_string().

New in version 1.0.

get_length()
Returns:

the length of the path.

Return type:

int

Retrieves an approximation of the total length of the path.

New in version 1.0.

get_n_nodes()
Returns:

the number of nodes.

Return type:

int

Retrieves the number of nodes in the path.

New in version 1.0.

get_node(index_)
Parameters:

index (int) – the node number to retrieve

Returns:

a location to store a copy of the node

Return type:

node: Clutter.PathNode

Retrieves the node of the path indexed by index.

New in version 1.0.

get_nodes()
Returns:

a list of nodes in the path.

Return type:

[Clutter.PathNode]

Returns a GLib.SList of Clutter.PathNode s. 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.

New in version 1.0.

get_position(progress)
Parameters:

progress (float) – a position along the path as a fraction of its length

Returns:

index of the node used to calculate the position.

position:

location to store the position

Return type:

(int, position: Clutter.Knot)

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.

New in version 1.0.

insert_node(index_, node)
Parameters:
  • index (int) – offset of where to insert the node

  • node (Clutter.PathNode) – the node to insert

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.

New in version 1.0.

remove_node(index_)
Parameters:

index (int) – index of the node to remove

Removes the node at the given offset from the path.

New in version 1.0.

replace_node(index_, node)
Parameters:

Replaces the node at offset index_ with node.

New in version 1.0.

set_description(str)
Parameters:

str (str) – a string describing the path

Returns:

True is the path was valid, False otherwise.

Return type:

bool

Replaces all of the nodes in the path with nodes described by str. See Clutter.Path.add_string() for details of the format.

If the string is invalid then False is returned and the path is unaltered.

New in version 1.0.

to_cairo_path(cr)
Parameters:

cr (cairo.Context) – a Cairo context

Add the nodes of the Clutter.Path to the path in the Cairo context.

New in version 1.0.

Property Details

Clutter.Path.props.description
Name:

description

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE

SVG-style description of the path

Clutter.Path.props.length
Name:

length

Type:

int

Default Value:

0

Flags:

READABLE

An approximation of the total length of the path.