An object describing a path with straight lines and bezier curves.
A <clutter-path>
contains a description of a path consisting of
straight lines and bezier curves. This can be used in a
<clutter-behaviour-path>
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:
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.
Creates a straight line from the previous point to the given point.
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.
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.
<clutter-path>
is available since Clutter 1.0
<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-behaviour-path>
then you do not need to unref it.
- ret
- the newly created
<clutter-path>
Since 1.0
mchars
) ⇒ (ret <clutter-path>
)Creates a new
<clutter-path>
instance with the nodes described in desc. Seeclutter-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-behaviour-path>
then you do not need to unref it.
- desc
- a string describing the path
- ret
- the newly created
<clutter-path>
Since 1.0
<clutter-path>
) (x int
) (y int
)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.
- path
- a
<clutter-path>
- x
- the x coordinate
- y
- the y coordinate
Since 1.0
<clutter-path>
) (x int
) (y int
)Same as
clutter-path-add-move-to
except the coordinates are relative to the previous node.
- path
- a
<clutter-path>
- x
- the x coordinate
- y
- the y coordinate
Since 1.0
<clutter-path>
) (x int
) (y int
)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.
- path
- a
<clutter-path>
- x
- the x coordinate
- y
- the y coordinate
Since 1.0
<clutter-path>
) (x int
) (y int
)Same as
clutter-path-add-line-to
except the coordinates are relative to the previous node.
- path
- a
<clutter-path>
- x
- the x coordinate
- y
- the y coordinate
Since 1.0
<clutter-path>
) (x_1 int
) (y_1 int
) (x_2 int
) (y_2 int
) (x_3 int
) (y_3 int
)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
- a
<clutter-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
<clutter-path>
) (x_1 int
) (y_1 int
) (x_2 int
) (y_2 int
) (x_3 int
) (y_3 int
)Same as
clutter-path-add-curve-to
except the coordinates are relative to the previous node.
- path
- a
<clutter-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
<clutter-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.
- path
- a
<clutter-path>
Since 1.0
<clutter-path>
) (str mchars
) ⇒ (ret 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:
- L
- C
- z
Adds a ‘CLUTTER_PATH_MOVE_TO’ node. Takes one pair of coordinates.
Adds a ‘CLUTTER_PATH_LINE_TO’ node. Takes one pair of coordinates.
Adds a ‘CLUTTER_PATH_CURVE_TO’ node. Takes three pairs of coordinates.
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 zIf the path description isn't valid ‘
#f
’ will be returned and no nodes will be added.
- path
- a
<clutter-path>
- str
- a string describing the new nodes
- ret
- ‘
#t
’ is the path description was valid or ‘#f
’ otherwise.Since 1.0
<clutter-path>
) (node <clutter-path-node>
)Adds node to the end of the path.
- path
- a
<clutter-path>
- node
- a
<clutter-path-node>
Since 1.0
<clutter-path>
) (cpath cairo-path-t
)Add the nodes of the Cairo path to the end of path.
- path
- a
<clutter-path>
- cpath
- a Cairo path
Since 1.0
<clutter-path>
) ⇒ (ret unsigned-int
)Retrieves the number of nodes in the path.
- path
- a
<clutter-path>
- ret
- the number of nodes.
Since 1.0
<clutter-path>
) (index_ unsigned-int
) (node <clutter-path-node>
)Retrieves the node of the path indexed by index.
- path
- a
<clutter-path>
- index
- the node number to retrieve
- node
- a location to store a copy of the node.
Since 1.0
<clutter-path>
) ⇒ (ret gslist-of
)Returns a
<gs-list>
of<clutter-path-node>
s. The list should be freed withg-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.
- path
- a
<clutter-path>
- ret
- a list of nodes in the path.
Since 1.0
<clutter-path>
) (index_ int
) (node <clutter-path-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.
- path
- a
<clutter-path>
- index
- offset of where to insert the node
- node
- the node to insert
Since 1.0
<clutter-path>
) (index_ unsigned-int
)Removes the node at the given offset from the path.
- path
- a
<clutter-path>
- index
- index of the node to remove
Since 1.0
<clutter-path>
) (index_ unsigned-int
) (node <clutter-path-node>
)Replaces the node at offset index with node.
- path
- a
<clutter-path>
- index
- index to the existing node
- node
- the replacement node
Since 1.0
<clutter-path>
) ⇒ (ret mchars
)Returns a newly allocated string describing the path in the same format as used by
clutter-path-add-string
.
- path
- a
<clutter-path>
- ret
- a string description of the path. Free with
g-free
.Since 1.0
<clutter-path>
) (str mchars
) ⇒ (ret 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 ‘
#f
’ is returned and the path is unaltered.
- path
- a
<clutter-path>
- str
- a string describing the path
- ret
- ‘
#t
’ is the path was valid, ‘#f
’ otherwise.Since 1.0
<clutter-path>
) (cr cairo-t
)Add the nodes of the ClutterPath to the path in the Cairo context.
- path
- a
<clutter-path>
- cr
- a Cairo context
Since 1.0
<clutter-path>
)Removes all nodes from the path.
- path
- a
<clutter-path>
Since 1.0
<clutter-path>
) (progress double
) (position <clutter-knot>
) ⇒ (ret unsigned-int
)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
- a
<clutter-path>
- progress
- a position along the path as a fraction of its length
- position
- location to store the position.
- ret
- index of the node used to calculate the position.
Since 1.0