Top | ![]() |
![]() |
![]() |
![]() |
ClutterPath | |
struct | ClutterPathClass |
enum | ClutterPathNodeType |
struct | ClutterPathNode |
A ClutterPath contains a description of a path consisting of straight lines and bezier curves. This can be used in a ClutterBehaviourPath to animate an actor moving along the path.
The path consists of a series of nodes. Each node is one of the following four types:
CLUTTER_PATH_MOVE_TO
, changes the position of the path to the
given pair of coordinates. This is usually used as the first node
of a path to mark the start position. If it is used in the middle
of a path then the path will be disjoint and the actor will appear
to jump to the new position when animated.
CLUTTER_PATH_LINE_TO
, creates a straight line from the previous
point to the given point.
CLUTTER_PATH_CURVE_TO
, creates a bezier curve. The end of the
last node is used as the first control point and the three
subsequent coordinates given in the node as used as the other three.
-CLUTTER_PATH_CLOSE
, creates a straight line from the last node to
the last CLUTTER_PATH_MOVE_TO
node. This can be used to close a
path so that it will appear as a loop when animated.
The first three types have the corresponding relative versions
CLUTTER_PATH_REL_MOVE_TO
, CLUTTER_PATH_REL_LINE_TO
and
CLUTTER_PATH_REL_CURVE_TO
. These are exactly the same except the
coordinates are given relative to the previous node instead of as
direct screen positions.
You can build a path using the node adding functions such as
clutter_path_add_line_to()
. Alternatively the path can be described
in a string using a subset of the SVG path syntax. See
clutter_path_add_string()
for details.
ClutterPath is available since Clutter 1.0
void (*ClutterPathCallback) (const ClutterPathNode *node
,gpointer data
);
This function is passed to clutter_path_foreach()
and will be
called for each node contained in the path.
Since 1.0
ClutterPath *
clutter_path_new (void
);
Creates a new ClutterPath instance with no nodes.
The object has a floating reference so if you add it to a ClutterBehaviourPath then you do not need to unref it.
Since 1.0
ClutterPath *
clutter_path_new_with_description (const gchar *desc
);
Creates a new ClutterPath 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 ClutterBehaviourPath then you do not need to unref it.
Since 1.0
void clutter_path_add_move_to (ClutterPath *path
,gint x
,gint y
);
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.
Since 1.0
void clutter_path_add_rel_move_to (ClutterPath *path
,gint x
,gint y
);
Same as clutter_path_add_move_to()
except the coordinates are
relative to the previous node.
Since 1.0
void clutter_path_add_line_to (ClutterPath *path
,gint x
,gint y
);
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.
Since 1.0
void clutter_path_add_rel_line_to (ClutterPath *path
,gint x
,gint y
);
Same as clutter_path_add_line_to()
except the coordinates are
relative to the previous node.
Since 1.0
void clutter_path_add_curve_to (ClutterPath *path
,gint x_1
,gint y_1
,gint x_2
,gint y_2
,gint x_3
,gint y_3
);
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.
path |
||
x_1 |
the x coordinate of the first control point |
|
y_1 |
the y coordinate of the first control point |
|
x_2 |
the x coordinate of the second control point |
|
y_2 |
the y coordinate of the second control point |
|
x_3 |
the x coordinate of the third control point |
|
y_3 |
the y coordinate of the third control point |
Since 1.0
void clutter_path_add_rel_curve_to (ClutterPath *path
,gint x_1
,gint y_1
,gint x_2
,gint y_2
,gint x_3
,gint y_3
);
Same as clutter_path_add_curve_to()
except the coordinates are
relative to the previous node.
path |
||
x_1 |
the x coordinate of the first control point |
|
y_1 |
the y coordinate of the first control point |
|
x_2 |
the x coordinate of the second control point |
|
y_2 |
the y coordinate of the second control point |
|
x_3 |
the x coordinate of the third control point |
|
y_3 |
the y coordinate of the third control point |
Since 1.0
void
clutter_path_add_close (ClutterPath *path
);
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.
Since 1.0
gboolean clutter_path_add_string (ClutterPath *path
,const gchar *str
);
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:
1 |
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.
Since 1.0
void clutter_path_add_node (ClutterPath *path
,const ClutterPathNode *node
);
Adds node
to the end of the path.
Since 1.0
void clutter_path_add_cairo_path (ClutterPath *path
,const cairo_path_t *cpath
);
Add the nodes of the Cairo path to the end of path
.
Since 1.0
guint
clutter_path_get_n_nodes (ClutterPath *path
);
Retrieves the number of nodes in the path.
Since 1.0
void clutter_path_get_node (ClutterPath *path
,guint index_
,ClutterPathNode *node
);
Retrieves the node of the path indexed by index
.
path |
||
index_ |
the node number to retrieve |
|
node |
a location to store a copy of the node. |
[out] |
Since 1.0
GSList *
clutter_path_get_nodes (ClutterPath *path
);
Returns a GSList of ClutterPathNode<!-- -->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.
Since 1.0
void clutter_path_foreach (ClutterPath *path
,ClutterPathCallback callback
,gpointer user_data
);
Calls a function for each node of the path.
path |
||
callback |
the function to call with each node. |
[scope call] |
user_data |
user data to pass to the function |
Since 1.0
void clutter_path_insert_node (ClutterPath *path
,gint index_
,const ClutterPathNode *node
);
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.
Since 1.0
void clutter_path_remove_node (ClutterPath *path
,guint index_
);
Removes the node at the given offset from the path.
Since 1.0
void clutter_path_replace_node (ClutterPath *path
,guint index_
,const ClutterPathNode *node
);
Replaces the node at offset index_
with node
.
Since 1.0
gchar *
clutter_path_get_description (ClutterPath *path
);
Returns a newly allocated string describing the path in the same
format as used by clutter_path_add_string()
.
Since 1.0
gboolean clutter_path_set_description (ClutterPath *path
,const gchar *str
);
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.
Since 1.0
void clutter_path_to_cairo_path (ClutterPath *path
,cairo_t *cr
);
Add the nodes of the ClutterPath to the path in the Cairo context.
Since 1.0
void
clutter_path_clear (ClutterPath *path
);
Removes all nodes from the path.
Since 1.0
guint clutter_path_get_position (ClutterPath *path
,gdouble progress
,ClutterKnot *position
);
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
.
path |
||
progress |
a position along the path as a fraction of its length |
|
position |
location to store the position. |
[out] |
Since 1.0
guint
clutter_path_get_length (ClutterPath *path
);
Retrieves an approximation of the total length of the path.
Since 1.0
ClutterPathNode *
clutter_path_node_copy (const ClutterPathNode *node
);
Makes an allocated copy of a node.
Since 1.0
void
clutter_path_node_free (ClutterPathNode *node
);
Frees the memory of an allocated node.
Since 1.0
gboolean clutter_path_node_equal (const ClutterPathNode *node_a
,const ClutterPathNode *node_b
);
Compares two nodes and checks if they are the same type with the same coordinates.
Since 1.0
typedef struct _ClutterPath ClutterPath;
The ClutterPath struct contains only private data and should be accessed with the functions below.
Since 1.0
struct ClutterPathClass { };
The ClutterPathClass struct contains only private data.
Since 1.0
Types of nodes in a ClutterPath.
jump to the given position |
||
create a line from the last node to the given position |
||
bezier curve using the last position and three control points. |
||
create a line from the last node to the last
|
||
same as |
||
same as |
||
same as |
Since 1.0
struct ClutterPathNode { ClutterPathNodeType type; ClutterKnot points[3]; };
Represents a single node of a ClutterPath.
Some of the coordinates in points
may be unused for some node
types. CLUTTER_PATH_MOVE_TO
and CLUTTER_PATH_LINE_TO
use only one
pair of coordinates, CLUTTER_PATH_CURVE_TO
uses all three and
CLUTTER_PATH_CLOSE
uses none.
ClutterPathNodeType |
the node's type |
|
ClutterKnot |
the coordinates of the node |
Since 1.0