Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Migrating to ClutterPath: Clutter Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="Clutter Reference Manual">
<link rel="up" href="migration.html" title="Part IX. Migrating from previous version of Clutter">
<link rel="prev" href="migrating-ClutterEffect.html" title="Migrating from ClutterEffect">
<link rel="next" href="iterating-paths.html" title="Iterating over a ClutterPath">
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="migration.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="migrating-ClutterEffect.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="iterating-paths.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="migrating-ClutterPath"></a>Migrating to ClutterPath</h2></div>
<div><div class="author">
<h3 class="author">
<span class="firstname">Emmanuele</span> <span class="surname">Bassi</span>
</h3>
<div class="affiliation"><div class="address"><p><br>
          <code class="email">&lt;<a class="email" href="mailto:ebassilinux.intel.com">ebassi<em class="parameter"><code>linux.intel.com</code></em></a>&gt;</code><br>
        </p></div></div>
</div></div>
</div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="migrating-ClutterPath.html#creating-paths">Creating a <span class="type">ClutterPath</span></a></span></dt>
<dt><span class="section"><a href="iterating-paths.html">Iterating over a <span class="type">ClutterPath</span></a></span></dt>
<dt><span class="section"><a href="using-cairo.html">Integration with Cairo</a></span></dt>
</dl></div>
<p>Between Clutter 0.8 and Clutter 1.0 the <a class="link" href="ClutterBehaviourPath.html" title="ClutterBehaviourPath"><span class="type">ClutterBehaviourPath</span></a>
  behaviour lost all the path manipulation functions and the
  <span class="structname">ClutterBehaviourBspline</span> class was entirely
  deprecated.</p>
<p>The class that replaced the path description and manipulation
  functionality is called <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a>. A <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> allows
  describing a path using a sequence of <a class="link" href="ClutterPath.html#ClutterPathNode"><span class="type">ClutterPathNode</span></a>s or
  using a subset of the SVG path description syntax. A Path instance
  also allows describing complex paths, with linear and Bezier segments
  and with gaps.</p>
<p>Finally, <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> also provides integration with Cairo,
  by being able to add paths described by the Cairo
  <span class="structname">cairo_path_t</span> data structure and being able
  to "replay" a <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> onto a <span class="structname">cairo_t</span>
  Cairo context.</p>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="creating-paths"></a>Creating a <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a>
</h2></div></div></div>
<p>Before Clutter 1.0, all the path-related functions inside
    <a class="link" href="ClutterBehaviourPath.html" title="ClutterBehaviourPath"><span class="type">ClutterBehaviourPath</span></a> and <span class="structname">ClutterBehaviourBspline</span>
    were replicated, but were also subtly different given the different nature
    of the types of path handled by the two <a class="link" href="ClutterBehaviour.html" title="ClutterBehaviour"><span class="type">ClutterBehaviour</span></a>s.</p>
<div class="example">
<a name="example-clutter-behaviour-path"></a><p class="title"><b>Example 5. ClutterBehaviourPath example</b></p>
<div class="example-contents">
<p>The following code shows how a <a class="link" href="ClutterBehaviourPath.html" title="ClutterBehaviourPath"><span class="type">ClutterBehaviourPath</span></a> was
      created prior to the introduction of <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a>. The path described
      is a square box between 100, 100 and 200, 200.</p>
<pre class="programlisting">
  ClutterBehaviour *behaviour;
  ClutterKnot knots[] = {
    { 100, 100 },
    { 200, 100 },
    { 200, 200 },
    { 100, 200 },
    { 100, 100 }
  };

  behaviour = clutter_behaviour_path_new (alpha, knots, G_N_ELEMENTS (knots));
      </pre>
</div>
</div>
<br class="example-break"><p>The construction for a B-Spline path behaviour was similar, though
    the <a class="link" href="clutter-Base-geometric-types.html#ClutterKnot"><span class="type">ClutterKnot</span></a>s could only describe a curvilinear path.</p>
<div class="example">
<a name="example-construct-clutter-path"></a><p class="title"><b>Example 6. Constructing ClutterPath</b></p>
<div class="example-contents">
<p>The following code shows how to construct a <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> and
      assign it to a <a class="link" href="ClutterBehaviourPath.html" title="ClutterBehaviourPath"><span class="type">ClutterBehaviourPath</span></a>. The created path is the same as
      the example above.</p>
<pre class="programlisting">
  ClutterBehaviour *behaviour;
  ClutterPath *path;

  path = clutter_path_new ();
  clutter_path_add_move_to (path, 100, 100);
  clutter_path_add_line_to (path, 200, 100);
  clutter_path_add_line_to (path, 200, 200);
  clutter_path_add_line_to (path, 100, 200);
  clutter_path_add_close (path);

  behaviour = clutter_behaviour_path_new (alpha, path);
      </pre>
</div>
</div>
<br class="example-break"><div class="note">A <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> object can be shared across behaviours, just
    like the <a class="link" href="ClutterAlpha.html" title="ClutterAlpha"><span class="type">ClutterAlpha</span></a> objects can.</div>
<p>Path can be described by using a subset of the SVG notation for
    paths as well as using <a class="link" href="ClutterPath.html#ClutterPathNode"><span class="type">ClutterPathNode</span></a> structures.</p>
<div class="example">
<a name="example-describe-clutter-path"></a><p class="title"><b>Example 7. Describing ClutterPath</b></p>
<div class="example-contents">
<p>The SVG path notation subset used by <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> is in
      string format and can be both set as the whole path description
      using <a class="link" href="ClutterPath.html#clutter-path-set-description" title="clutter_path_set_description ()"><code class="function">clutter_path_set_description()</code></a> or can be added to an
      existing <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> using <a class="link" href="ClutterPath.html#clutter-path-add-string" title="clutter_path_add_string ()"><code class="function">clutter_path_add_string()</code></a>. The following
      example shows the same path as the two examples above.</p>
<pre class="programlisting">
  ClutterPath *path = clutter_path_new ();

  clutter_path_set_description (path,
                                "M 100,100 " /* move to */
                                "L 200,100 " /* line to */
                                "L 200,200 "
                                "L 100,200 "
                                "z"          /* close   */);
      </pre>
</div>
</div>
<br class="example-break"><p>A <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a> can describe not only linear, closed paths; it
    can also describe paths with Beziér curvers and can add gaps.</p>
<div class="example">
<a name="example-describe-mixed-clutter-path"></a><p class="title"><b>Example 8. Describing a mixed ClutterPath</b></p>
<div class="example-contents">
<p>A mixed <a class="link" href="ClutterPath.html" title="ClutterPath"><span class="type">ClutterPath</span></a>, with a Beziér curve between the point
      at 200, 200 and 100, 100 and both control points in 100, 200.</p>
<pre class="programlisting">
  ClutterPath *path = clutter_path_new ();

  clutter_path_set_description (path,
                                "M 100,100 "
                                "L 200,100 "
                                "L 200,200 "
                                "C 100,200 100,200 100,100");
      </pre>
</div>
</div>
<br class="example-break">
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25.1</div>
</body>
</html>