Emmanuele Bassi > Clutter > xs/ClutterPath.xs

Download:
Clutter-1.002.tar.gz

Annotate this POD

CPAN RT

New  2
Open  2
View Bugs
Report a bug
Source  

DESCRIPTION ^

A Clutter::Path::Node is a node inside a Clutter::Path. Each node is represented by a hash reference with two keys: type and points. The value for type can be one of the following:

move-to
line-to
curve-to
close

The value for points is an array reference which contains zero or more points. Points are represented by either a hash reference with two keys x and y, or by an array reference that contains two doubles.

The necessary number of points depends on the type of the path node:

move-to: 1 point
line-to: 1 point
curve-to: 3 points
close: 0 points

The semantics and ordering of the coordinate values are consistent with Clutter::Path::add_move_to(), Clutter::Path::add_line_to(), Clutter::Path::add_curve_to() and Clutter::Path::add_close().

DESCRIPTION ^

A Clutter::Path contains a description of a path consisting of straight lines and Bezier curves. This can be used in a Clutter::BehaviourPath to animate an actor moving along the path.

The path consists of a series of nodes; see Clutter::PathNode for more information on the node notation.

You can build a path using the node adding functions such as Clutter::Path::add_line_to() or Clutter::Path::add_curve_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.

The optional arguments can be a stringified definition of the path, using a subset of the SVG path syntax or a list of nodes, e.g.:

    Clutter::Path->new("M 10,10 L 200,200 z");

    # or the equivalent

    Clutter::Path->new(
        [ 'move-to', [ [ 10, 10 ] ] ],
        [ 'line-to', [ [ 200, 200 ] ] ],
        [ 'close' ],
    );

See Clutter::Path::add_string() for the format of the path description.

This method is useful in case you store a path as Clutter::Path and wish to paint it on a Clutter::CairoTexture

The function will have the following parameters:

node

The current node in the path

data

The data passed to Clutter::Path::foreach()

In array context this method will also return the knot with the position on the path given the value of progress.

The progress is a floating point value between 0.0 and 1.0; it usually comes from a Clutter::Alpha or a Clutter::Interval.

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 - equivalent 'move-to'/'CLUTTER_PATH_MOVE_TO' =item m - equivalent 'rel-move-to'/'CLUTTER_PATH_REL_MOVE_TO'

Take one pair of coordinates

L - equivalent to 'line-to'/'CLUTTER_PATH_LINE_TO' =item l - equivalent to 'rel-line-to'/'CLUTTER_PATH_REL_LINE_TO'

Take one pair of coordinates

C - equivalent to 'curve-to'/'CLUTTER_PATH_CURVE_TO' =item c - equivalent to 'rel-curve-to'/'CLUTTER_PATH_REL_CURVE_TO'

Take three pairs of coordinates

z - equivalent to 'close'/'CLUTTER_PATH_CLOSE'

No coordinates needed

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

This function may croak on failure.