1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Creating Animations with Clutter</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="Clutter Reference Manual">
8 <link rel="up" href="additionaldocs.html" title="Part VIII. Additional Documentation">
9 <link rel="prev" href="additionaldocs.html" title="Part VIII. Additional Documentation">
10 <link rel="next" href="clutter-animation-timelines.html" title="Timelines">
11 <meta name="generator" content="GTK-Doc V1.18.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="additionaldocs.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="additionaldocs.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">Clutter Reference Manual</th>
20 <td><a accesskey="n" href="clutter-animation-timelines.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <div class="titlepage"><div>
24 <div><h2 class="title">
25 <a name="clutter-animations"></a>Creating Animations with Clutter</h2></div>
26 <div><div class="author">
28 <span class="firstname">Matthew</span> <span class="surname">Allum</span>
30 <div class="affiliation"><div class="address"><p><br>
31 <code class="email"><<a class="email" href="mailto:mallumopenedhand.com">mallum<em class="parameter"><code>openedhand.com</code></em></a>></code><br>
34 <div><div class="author">
36 <span class="firstname">Emmanuele</span> <span class="surname">Bassi</span>
38 <div class="affiliation"><div class="address"><p><br>
39 <code class="email"><<a class="email" href="mailto:ebassilinux.intel.com">ebassi<em class="parameter"><code>linux.intel.com</code></em></a>></code><br>
44 <dt><span class="section"><a href="clutter-animations.html#clutter-animation-basic">Basic Animations</a></span></dt>
45 <dt><span class="section"><a href="clutter-animation-timelines.html">Timelines</a></span></dt>
46 <dt><span class="section"><a href="clutter-animation-implicit.html">Implicit Animations</a></span></dt>
47 <dt><span class="section"><a href="clutter-animation-conclusion.html">Conclusion</a></span></dt>
49 <p>With Clutter using hardware accelration for graphics rendering,
50 complex and fast animations are possible. This chapter describes basic
51 techniques and the utilities Clutter provides in aiding animation
54 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
55 <a name="clutter-animation-basic"></a>Basic Animations</h2></div></div></div>
56 <p>The most basic way to create animations with Clutter is via the use
57 of <a class="link" href="clutter-General.html#clutter-threads-add-timeout" title="clutter_threads_add_timeout ()"><code class="function">clutter_threads_add_timeout()</code></a>. This enables a callback function to be
58 called at a defined interval. The callback function can then modify actors
59 visual properties as to produce an animation.</p>
61 <a name="clutter-timeout-example"></a><p class="title"><b>Example 18. Simple timeout example</b></p>
62 <div class="example-contents">
63 <p>Implement a rotating actor using 360 "frames"</p>
64 <pre class="programlisting">
65 struct RotationClosure {
69 gdouble current_angle;
73 rotate_actor (gpointer data)
75 struct RotationClosure *clos = data;
77 clutter_actor_set_rotation (clos->actor, clos->current_angle, 0, 0, 0);
80 clos->current_angle += 1.0
82 /* if we reached the target angle, stop */
83 if (clos->current_angle == clos->final_angle)
84 return G_SOURCE_REMOVE;
86 return G_SOURCE_CONTINUE;
90 rotate_actor_cleanup (gpointer data)
92 struct RotationClosure *clos = data;
94 g_object_unref (clos->actor);
99 struct RotationClosure *clos = NULL;
101 clos = g_new (struct RotationClosure, 1);
102 clos->actor = g_object_ref (an_actor);
103 clos->final_angle = 360.0;
104 clos->current_angle = 0;
106 clutter_threads_add_timeout_full (G_PRIORITY_DEFAULT,
107 1000 / 360, /* 360 updates in one second */
110 rotate_actor_cleanup);
114 <br class="example-break"><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
115 <h3 class="title">Priorities</h3>
116 <p><a href="../glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS"><code class="literal">G_PRIORITY_DEFAULT</code></a> should always be used as the timeouts priority
117 (in case of <a class="link" href="clutter-General.html#clutter-threads-add-timeout-full" title="clutter_threads_add_timeout_full ()"><code class="function">clutter_threads_add_timeout_full()</code></a>) as not to intefere with
118 Clutter's scheduling of repaints and input event handling.</p>
124 Generated by GTK-Doc V1.18.1</div>