/usr/share/qt5/doc/qtquick/qtquick-animation-example.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- animation.qdoc -->
<title>Qt Quick Examples - Animation | Qt Quick 5.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtquick-index.html">Qt Quick</a></li>
<li>Qt Quick Examples - Animation</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#coloranimation">ColorAnimation</a></li>
<li class="level1"><a href="#propertyanimation">PropertyAnimation</a></li>
<li class="level1"><a href="#animators">Animators</a></li>
<li class="level1"><a href="#behaviors">Behaviors</a></li>
<li class="level1"><a href="#wiggly-text">Wiggly Text</a></li>
<li class="level1"><a href="#tv-tennis">Tv Tennis</a></li>
<li class="level1"><a href="#easing-curves">Easing Curves</a></li>
<li class="level1"><a href="#states">States</a></li>
<li class="level1"><a href="#transitions">Transitions</a></li>
<li class="level1"><a href="#pathanimation">PathAnimation</a></li>
<li class="level1"><a href="#pathinterpolator">PathInterpolator</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick Examples - Animation</h1>
<span class="subtitle"></span>
<!-- $$$animation-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/qml-animations-example.png" alt="" /></p><p><i>Animation</i> is a collection of small QML examples relating to animation. Each example is a small QML file emphasizing a particular type or feature.</p>
<p>For more information about animations, visit <a href="qtquick-statesanimations-topic.html">Important Concepts in Qt Quick - States, Transitions and Animations</a>.</p>
<a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="coloranimation"></a>
<h2 id="coloranimation">ColorAnimation</h2>
<p><i>ColorAnimation</i> uses color animations to fade a sky from day to night.</p>
<pre class="qml"><span class="name">gradient</span>: <span class="name">Gradient</span> {
<span class="type"><a href="qml-qtquick-gradientstop.html">GradientStop</a></span> {
<span class="name">position</span>: <span class="number">0.0</span>
SequentialAnimation on <span class="name">color</span> {
<span class="name">loops</span>: <span class="name">Animation</span>.<span class="name">Infinite</span>
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">from</span>: <span class="string">"#14148c"</span>; <span class="name">to</span>: <span class="string">"#0E1533"</span>; <span class="name">duration</span>: <span class="number">5000</span> }
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">from</span>: <span class="string">"#0E1533"</span>; <span class="name">to</span>: <span class="string">"#14148c"</span>; <span class="name">duration</span>: <span class="number">5000</span> }
}
}
<span class="type"><a href="qml-qtquick-gradientstop.html">GradientStop</a></span> {
<span class="name">position</span>: <span class="number">1.0</span>
SequentialAnimation on <span class="name">color</span> {
<span class="name">loops</span>: <span class="name">Animation</span>.<span class="name">Infinite</span>
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">from</span>: <span class="string">"#14aaff"</span>; <span class="name">to</span>: <span class="string">"#437284"</span>; <span class="name">duration</span>: <span class="number">5000</span> }
<span class="type"><a href="qml-qtquick-coloranimation.html">ColorAnimation</a></span> { <span class="name">from</span>: <span class="string">"#437284"</span>; <span class="name">to</span>: <span class="string">"#14aaff"</span>; <span class="name">duration</span>: <span class="number">5000</span> }
}
}
}</pre>
<a name="propertyanimation"></a>
<h2 id="propertyanimation">PropertyAnimation</h2>
<p><i>PropertyAnimation</i> uses number animations to bounce a circle up and down.</p>
<pre class="qml"><span class="comment">// Animate the y property. Setting loops to Animation.Infinite makes the</span>
<span class="comment">// animation repeat indefinitely, otherwise it would only run once.</span>
SequentialAnimation on <span class="name">y</span> {
<span class="name">loops</span>: <span class="name">Animation</span>.<span class="name">Infinite</span>
<span class="comment">// Move from minHeight to maxHeight in 300ms, using the OutExpo easing function</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> {
<span class="name">from</span>: <span class="name">smiley</span>.<span class="name">minHeight</span>; <span class="name">to</span>: <span class="name">smiley</span>.<span class="name">maxHeight</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutExpo</span>; <span class="name">duration</span>: <span class="number">300</span>
}
<span class="comment">// Then move back to minHeight in 1 second, using the OutBounce easing function</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> {
<span class="name">from</span>: <span class="name">smiley</span>.<span class="name">maxHeight</span>; <span class="name">to</span>: <span class="name">smiley</span>.<span class="name">minHeight</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutBounce</span>; <span class="name">duration</span>: <span class="number">1000</span>
}
<span class="comment">// Then pause for 500ms</span>
<span class="type"><a href="qml-qtquick-pauseanimation.html">PauseAnimation</a></span> { <span class="name">duration</span>: <span class="number">500</span> }
}</pre>
<a name="animators"></a>
<h2 id="animators">Animators</h2>
<p><i>Animators</i> uses animators to bounce an icon up and down.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a></span> {
<span class="type"><a href="qml-qtquick-sequentialanimation.html">SequentialAnimation</a></span> {
<span class="type"><a href="qml-qtquick-parallelanimation.html">ParallelAnimation</a></span> {
<span class="type"><a href="qml-qtquick-yanimator.html">YAnimator</a></span> {
<span class="name">target</span>: <span class="name">smiley</span>;
<span class="name">from</span>: <span class="name">smiley</span>.<span class="name">minHeight</span>;
<span class="name">to</span>: <span class="name">smiley</span>.<span class="name">maxHeight</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutExpo</span>;
<span class="name">duration</span>: <span class="number">300</span>
}
<span class="type"><a href="qml-qtquick-scaleanimator.html">ScaleAnimator</a></span> {
<span class="name">target</span>: <span class="name">shadow</span>
<span class="name">from</span>: <span class="number">1</span>
<span class="name">to</span>: <span class="number">0.5</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutExpo</span>;
<span class="name">duration</span>: <span class="number">300</span>
}
}
<span class="type"><a href="qml-qtquick-parallelanimation.html">ParallelAnimation</a></span> {
<span class="type"><a href="qml-qtquick-yanimator.html">YAnimator</a></span> {
<span class="name">target</span>: <span class="name">smiley</span>;
<span class="name">from</span>: <span class="name">smiley</span>.<span class="name">maxHeight</span>;
<span class="name">to</span>: <span class="name">smiley</span>.<span class="name">minHeight</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutBounce</span>;
<span class="name">duration</span>: <span class="number">1000</span>
}
<span class="type"><a href="qml-qtquick-scaleanimator.html">ScaleAnimator</a></span> {
<span class="name">target</span>: <span class="name">shadow</span>
<span class="name">from</span>: <span class="number">0.5</span>
<span class="name">to</span>: <span class="number">1</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutBounce</span>;
<span class="name">duration</span>: <span class="number">1000</span>
}
}
}
<span class="type"><a href="qml-qtquick-pauseanimation.html">PauseAnimation</a></span> { <span class="name">duration</span>: <span class="number">500</span> }
<span class="name">running</span>: <span class="number">true</span>
<span class="name">loops</span>: <span class="name">Animation</span>.<span class="name">Infinite</span>
}</pre>
<a name="behaviors"></a>
<h2 id="behaviors">Behaviors</h2>
<p><i>Behaviors</i> uses behaviors to move a rectangle to where you click.</p>
<pre class="qml"><span class="comment">// Set an 'elastic' behavior on the focusRect's y property.</span>
Behavior on <span class="name">y</span> {
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutElastic</span>; <span class="name">easing</span>.amplitude: <span class="number">3.0</span>; <span class="name">easing</span>.period: <span class="number">2.0</span>; <span class="name">duration</span>: <span class="number">300</span> }
}</pre>
<a name="wiggly-text"></a>
<h2 id="wiggly-text">Wiggly Text</h2>
<p><i>Wiggly Text</i> demonstrates using more complex behaviors to animate and wiggle some text around as you drag it. It does this by assigning a complex binding to each letter:</p>
<pre class="qml"> <span class="name">x</span>: <span class="name">follow</span> ? <span class="name">follow</span>.<span class="name">x</span> <span class="operator">+</span> <span class="name">follow</span>.<span class="name">width</span> : <span class="name">container</span>.<span class="name">width</span> <span class="operator">/</span> <span class="number">6</span>
<span class="name">y</span>: <span class="name">follow</span> ? <span class="name">follow</span>.<span class="name">y</span> : <span class="name">container</span>.<span class="name">height</span> <span class="operator">/</span> <span class="number">2</span></pre>
<p>Then, it uses behaviors to animate the movement of each letter:</p>
<pre class="qml"> Behavior on <span class="name">x</span> { <span class="name">enabled</span>: <span class="name">container</span>.<span class="name">animated</span>; <span class="type"><a href="qml-qtquick-springanimation.html">SpringAnimation</a></span> { <span class="name">spring</span>: <span class="number">3</span>; <span class="name">damping</span>: <span class="number">0.3</span>; <span class="name">mass</span>: <span class="number">1.0</span> } }
Behavior on <span class="name">y</span> { <span class="name">enabled</span>: <span class="name">container</span>.<span class="name">animated</span>; <span class="type"><a href="qml-qtquick-springanimation.html">SpringAnimation</a></span> { <span class="name">spring</span>: <span class="number">3</span>; <span class="name">damping</span>: <span class="number">0.3</span>; <span class="name">mass</span>: <span class="number">1.0</span> } }</pre>
<a name="tv-tennis"></a>
<h2 id="tv-tennis">Tv Tennis</h2>
<p><i>Tv Tennis</i> uses complex behaviors to make the paddles follow a ball to simulate an infinite tennis game. Again, a binding which depends on other values is applied to the position and a behavior provided the animation.</p>
<pre class="qml"><span class="name">y</span>: <span class="name">ball</span>.<span class="name">direction</span> <span class="operator">==</span> <span class="string">'left'</span> ? <span class="name">ball</span>.<span class="name">y</span> <span class="operator">-</span> <span class="number">45</span> : <span class="name">page</span>.<span class="name">height</span><span class="operator">/</span><span class="number">2</span> <span class="operator">-</span><span class="number">45</span>;
Behavior on <span class="name">y</span> { <span class="type"><a href="qml-qtquick-springanimation.html">SpringAnimation</a></span>{ <span class="name">velocity</span>: <span class="number">300</span> } }</pre>
<a name="easing-curves"></a>
<h2 id="easing-curves">Easing Curves</h2>
<p><i>Easing Curves</i> shows off all the easing curves available in Qt Quick animations.</p>
<a name="states"></a>
<h2 id="states">States</h2>
<p><i>States</i> demonstrates how the properties of an item can vary between <a href="qtquick-statesanimations-states.html">states</a>.</p>
<p>It defines several states:</p>
<pre class="qml"><span class="comment">// In state 'middleRight', move the image to middleRightRect</span>
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">"middleRight"</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">userIcon</span>; <span class="name">x</span>: <span class="name">middleRightRect</span>.<span class="name">x</span>; <span class="name">y</span>: <span class="name">middleRightRect</span>.<span class="name">y</span> }
},
<span class="comment">// In state 'bottomLeft', move the image to bottomLeftRect</span>
<span class="type"><a href="qml-qtquick-state.html">State</a></span> {
<span class="name">name</span>: <span class="string">"bottomLeft"</span>
<span class="type"><a href="qml-qtquick-propertychanges.html">PropertyChanges</a></span> { <span class="name">target</span>: <span class="name">userIcon</span>; <span class="name">x</span>: <span class="name">bottomLeftRect</span>.<span class="name">x</span>; <span class="name">y</span>: <span class="name">bottomLeftRect</span>.<span class="name">y</span> }
}</pre>
<a name="transitions"></a>
<h2 id="transitions">Transitions</h2>
<p><i>Transitions</i> takes the States example and animates the property changes by setting transitions:</p>
<pre class="qml"><span class="comment">// Transitions define how the properties change when the item moves between each state</span>
<span class="name">transitions</span>: [
<span class="comment">// When transitioning to 'middleRight' move x,y over a duration of 1 second,</span>
<span class="comment">// with OutBounce easing function.</span>
<span class="type"><a href="qml-qtquick-transition.html">Transition</a></span> {
<span class="name">from</span>: <span class="string">"*"</span>; <span class="name">to</span>: <span class="string">"middleRight"</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">properties</span>: <span class="string">"x,y"</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">OutBounce</span>; <span class="name">duration</span>: <span class="number">1000</span> }
},
<span class="comment">// When transitioning to 'bottomLeft' move x,y over a duration of 2 seconds,</span>
<span class="comment">// with InOutQuad easing function.</span>
<span class="type"><a href="qml-qtquick-transition.html">Transition</a></span> {
<span class="name">from</span>: <span class="string">"*"</span>; <span class="name">to</span>: <span class="string">"bottomLeft"</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">properties</span>: <span class="string">"x,y"</span>; <span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InOutQuad</span>; <span class="name">duration</span>: <span class="number">2000</span> }
},
<span class="comment">// For any other state changes move x,y linearly over duration of 200ms.</span>
<span class="type"><a href="qml-qtquick-transition.html">Transition</a></span> {
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">properties</span>: <span class="string">"x,y"</span>; <span class="name">duration</span>: <span class="number">200</span> }
}</pre>
<a name="pathanimation"></a>
<h2 id="pathanimation">PathAnimation</h2>
<p><i>PathAnimation</i> animates an image along a bezier curve using a <a href="qtquick-animation-example.html#pathanimation">PathAnimation</a>.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-pathanimation.html">PathAnimation</a></span> {
<span class="name">id</span>: <span class="name">pathAnim</span>
<span class="name">duration</span>: <span class="number">2000</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InQuad</span>
<span class="name">target</span>: <span class="name">box</span>
<span class="name">orientation</span>: <span class="name">PathAnimation</span>.<span class="name">RightFirst</span>
<span class="name">anchorPoint</span>: <span class="name">Qt</span>.<span class="name">point</span>(<span class="name">box</span>.<span class="name">width</span><span class="operator">/</span><span class="number">2</span>, <span class="name">box</span>.<span class="name">height</span><span class="operator">/</span><span class="number">2</span>)
<span class="name">path</span>: <span class="name">Path</span> {
<span class="name">startX</span>: <span class="number">50</span>; <span class="name">startY</span>: <span class="number">50</span>
<span class="type"><a href="qml-qtquick-pathcubic.html">PathCubic</a></span> {
<span class="name">x</span>: <span class="name">window</span>.<span class="name">width</span> <span class="operator">-</span> <span class="number">50</span>
<span class="name">y</span>: <span class="name">window</span>.<span class="name">height</span> <span class="operator">-</span> <span class="number">50</span>
<span class="name">control1X</span>: <span class="name">x</span>; <span class="name">control1Y</span>: <span class="number">50</span>
<span class="name">control2X</span>: <span class="number">50</span>; <span class="name">control2Y</span>: <span class="name">y</span>
}
<span class="name">onChanged</span>: <span class="name">canvas</span>.<span class="name">requestPaint</span>()
}
}</pre>
<a name="pathinterpolator"></a>
<h2 id="pathinterpolator">PathInterpolator</h2>
<p><i>PathInterpolator</i> animates an image along the same bezier curve, using a <a href="qtquick-animation-example.html#pathinterpolator">PathInterpolator</a> instead.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-pathinterpolator.html">PathInterpolator</a></span> {
<span class="name">id</span>: <span class="name">motionPath</span>
<span class="name">path</span>: <span class="name">Path</span> {
<span class="name">startX</span>: <span class="number">50</span>; <span class="name">startY</span>: <span class="number">50</span>
<span class="type"><a href="qml-qtquick-pathcubic.html">PathCubic</a></span> {
<span class="name">x</span>: <span class="name">window</span>.<span class="name">width</span> <span class="operator">-</span> <span class="number">50</span>
<span class="name">y</span>: <span class="name">window</span>.<span class="name">height</span> <span class="operator">-</span> <span class="number">50</span>
<span class="name">control1X</span>: <span class="name">x</span>; <span class="name">control1Y</span>: <span class="number">50</span>
<span class="name">control2X</span>: <span class="number">50</span>; <span class="name">control2Y</span>: <span class="name">y</span>
}
<span class="name">onChanged</span>: <span class="name">canvas</span>.<span class="name">requestPaint</span>()
}
SequentialAnimation on <span class="name">progress</span> {
<span class="name">running</span>: <span class="number">true</span>
<span class="name">loops</span>: -<span class="number">1</span>
<span class="type"><a href="qml-qtquick-pauseanimation.html">PauseAnimation</a></span> { <span class="name">duration</span>: <span class="number">1000</span> }
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> {
<span class="name">id</span>: <span class="name">progressAnim</span>
<span class="name">running</span>: <span class="number">false</span>
<span class="name">from</span>: <span class="number">0</span>; <span class="name">to</span>: <span class="number">1</span>
<span class="name">duration</span>: <span class="number">2000</span>
<span class="name">easing</span>.type: <span class="name">Easing</span>.<span class="name">InQuad</span>
}
}
}</pre>
<p>Files:</p>
<ul>
<li><a href="qtquick-animation-animation-qml.html">animation/animation.qml</a></li>
<li><a href="qtquick-animation-basics-animators-qml.html">animation/basics/animators.qml</a></li>
<li><a href="qtquick-animation-basics-color-animation-qml.html">animation/basics/color-animation.qml</a></li>
<li><a href="qtquick-animation-basics-property-animation-qml.html">animation/basics/property-animation.qml</a></li>
<li><a href="qtquick-animation-behaviors-siderect-qml.html">animation/behaviors/SideRect.qml</a></li>
<li><a href="qtquick-animation-behaviors-behavior-example-qml.html">animation/behaviors/behavior-example.qml</a></li>
<li><a href="qtquick-animation-behaviors-tvtennis-qml.html">animation/behaviors/tvtennis.qml</a></li>
<li><a href="qtquick-animation-behaviors-wigglytext-qml.html">animation/behaviors/wigglytext.qml</a></li>
<li><a href="qtquick-animation-easing-easing-qml.html">animation/easing/easing.qml</a></li>
<li><a href="qtquick-animation-pathanimation-pathanimation-qml.html">animation/pathanimation/pathanimation.qml</a></li>
<li><a href="qtquick-animation-pathinterpolator-pathinterpolator-qml.html">animation/pathinterpolator/pathinterpolator.qml</a></li>
<li><a href="qtquick-animation-states-states-qml.html">animation/states/states.qml</a></li>
<li><a href="qtquick-animation-states-transitions-qml.html">animation/states/transitions.qml</a></li>
<li><a href="qtquick-animation-main-cpp.html">animation/main.cpp</a></li>
<li><a href="qtquick-animation-animation-pro.html">animation/animation.pro</a></li>
<li><a href="qtquick-animation-animation-qmlproject.html">animation/animation.qmlproject</a></li>
<li><a href="qtquick-animation-animation-qrc.html">animation/animation.qrc</a></li>
</ul>
</div>
<!-- @@@animation -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|