<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- imageparticle.qdoc --> <title>Qt Quick Particles Examples - Image Particles | Qt Quick 5.9</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.9</td><td ><a href="qtquick-index.html">Qt Quick</a></td><td >Qt Quick Particles Examples - Image Particles</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">Qt Quick Particles Examples - Image Particles</h1> <span class="subtitle"></span> <!-- $$$particles/imageparticle-description --> <div class="descr"> <a name="details"></a> <p class="centerAlign"><img src="images/qml-imageparticle-example.png" alt="" /></p><p>This is a collection of small QML examples relating to using Affectors in the particle system. Each example is a small QML file emphasizing a particular type or feature.</p> <p>All at once shows off several of the features of <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a> at the same time.</p> <pre class="qml"> <span class="name">sprites</span>: [ <span class="type"><a href="qml-qtquick-sprite.html">Sprite</a></span> { <span class="name">name</span>: <span class="string">"bear"</span> <span class="name">source</span>: <span class="string">"../../images/bear_tiles.png"</span> <span class="name">frameCount</span>: <span class="number">13</span> <span class="name">frameDuration</span>: <span class="number">120</span> } ] <span class="name">colorVariation</span>: <span class="number">0.5</span> <span class="name">rotationVelocityVariation</span>: <span class="number">360</span> <span class="name">colorTable</span>: <span class="string">"../../images/colortable.png"</span> </pre> <p>Colored shows a simple <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a> with some color variation.</p> <pre class="qml"> <span class="type"><a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a></span> { <span class="name">anchors</span>.fill: <span class="name">parent</span> <span class="name">source</span>: <span class="string">"qrc:///particleresources/star.png"</span> <span class="name">alpha</span>: <span class="number">0</span> <span class="name">alphaVariation</span>: <span class="number">0.2</span> <span class="name">colorVariation</span>: <span class="number">1.0</span> } </pre> <p>Color Table sets the color over life on the particles to provide a fixed rainbow effect.</p> <pre class="qml"> <span class="name">source</span>: <span class="string">"qrc:///particleresources/glowdot.png"</span> <span class="name">colorTable</span>: <span class="string">"../../images/colortable.png"</span> <span class="name">sizeTable</span>: <span class="string">"../../images/colortable.png"</span> </pre> <p>Deformation spins and squishes a starfish particle.</p> <pre class="qml"> <span class="type"><a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a></span> { <span class="name">system</span>: <span class="name">sys</span> <span class="name">groups</span>: [<span class="string">"goingLeft"</span>, <span class="string">"goingRight"</span>] <span class="name">source</span>: <span class="string">"../../images/starfish_4.png"</span> <span class="name">rotation</span>: <span class="number">90</span> <span class="name">rotationVelocity</span>: <span class="number">90</span> <span class="name">autoRotation</span>: <span class="number">true</span> } <span class="type"><a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a></span> { <span class="name">system</span>: <span class="name">sys</span> <span class="name">groups</span>: [<span class="string">"goingDown"</span>] <span class="name">source</span>: <span class="string">"../../images/starfish_0.png"</span> <span class="name">rotation</span>: <span class="number">180</span> <span class="name">yVector</span>: <span class="name">PointDirection</span> { <span class="name">y</span>: <span class="number">0.5</span>; <span class="name">yVariation</span>: <span class="number">0.25</span>; <span class="name">xVariation</span>: <span class="number">0.25</span>; } } </pre> <p>Rotation demonstrates the autoRotate property, so that particles rotate in the direction that they travel.</p> <p>Sharing demonstrates what happens when multiple ImageParticles try to render the same particle. The following <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a> renders the particles inside the <a href="qml-qtquick-listview.html">ListView</a>:</p> <pre class="qml"> <span class="type"><a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a></span> { <span class="name">anchors</span>.fill: <span class="name">parent</span> <span class="name">system</span>: <span class="name">particles</span> <span class="name">source</span>: <span class="string">"../../images/flower.png"</span> <span class="name">alpha</span>: <span class="number">0.1</span> <span class="name">color</span>: <span class="string">"white"</span> <span class="name">rotationVariation</span>: <span class="number">180</span> <span class="name">z</span>: -<span class="number">1</span> } </pre> <p>The following <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a> is placed inside the list highlight, and renders the particles above the other <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a>.</p> <pre class="qml"> <span class="type"><a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a></span> { <span class="name">anchors</span>.fill: <span class="name">parent</span> <span class="name">system</span>: <span class="name">particles</span> <span class="name">source</span>: <span class="string">"../../images/flower.png"</span> <span class="name">color</span>: <span class="string">"red"</span> <span class="name">clip</span>: <span class="number">true</span> <span class="name">alpha</span>: <span class="number">1.0</span> } </pre> <p>Note that because it sets the color and alpha in this <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a>, it renders the particles in a different color. Since it doesn't specify anything about the rotation, it shares the rotation with the other <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a> so that the flowers are rotated the same way in both. Note that you can undo rotation in another <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a>, you just need to explicitly set rotationVariation to 0.</p> <p>Sprites demonstrates using an image particle to render animated sprites instead of static images for each particle.</p> <p>Files:</p> <ul> <li><a href="qtquick-particles-imageparticle-imageparticle-qml.html">particles/imageparticle/imageparticle.qml</a></li> <li><a href="qtquick-particles-imageparticle-content-allatonce-qml.html">particles/imageparticle/content/allatonce.qml</a></li> <li><a href="qtquick-particles-imageparticle-content-colored-qml.html">particles/imageparticle/content/colored.qml</a></li> <li><a href="qtquick-particles-imageparticle-content-colortable-qml.html">particles/imageparticle/content/colortable.qml</a></li> <li><a href="qtquick-particles-imageparticle-content-deformation-qml.html">particles/imageparticle/content/deformation.qml</a></li> <li><a href="qtquick-particles-imageparticle-content-rotation-qml.html">particles/imageparticle/content/rotation.qml</a></li> <li><a href="qtquick-particles-imageparticle-content-sharing-qml.html">particles/imageparticle/content/sharing.qml</a></li> <li><a href="qtquick-particles-imageparticle-content-sprites-qml.html">particles/imageparticle/content/sprites.qml</a></li> <li><a href="qtquick-particles-imageparticle-main-cpp.html">particles/imageparticle/main.cpp</a></li> <li><a href="qtquick-particles-imageparticle-imageparticle-pro.html">particles/imageparticle/imageparticle.pro</a></li> <li><a href="qtquick-particles-imageparticle-imageparticle-qmlproject.html">particles/imageparticle/imageparticle.qmlproject</a></li> <li><a href="qtquick-particles-imageparticle-imageparticle-qrc.html">particles/imageparticle/imageparticle.qrc</a></li> </ul> </div> <!-- @@@particles/imageparticle --> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 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>