/usr/share/qt5/doc/qtquick/qtquick-particles-system-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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- system.qdoc -->
<title>Qt Quick Particles Examples - System | 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 Particles Examples - System</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="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Qt Quick Particles Examples - System</h1>
<span class="subtitle"></span>
<!-- $$$particles/system-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/qml-system-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>Dynamic comparison compares using the particle system to getting a similar effect with the following code that dynamically instantiates Image types.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
<span class="name">id</span>: <span class="name">fakeEmitter</span>
<span class="keyword">function</span> <span class="name">burst</span>(<span class="name">number</span>) {
<span class="keyword">while</span> (<span class="name">number</span> <span class="operator">></span> <span class="number">0</span>) {
var <span class="name">item</span> = <span class="name">fakeParticle</span>.<span class="name">createObject</span>(<span class="name">root</span>);
<span class="name">item</span>.<span class="name">lifeSpan</span> <span class="operator">=</span> <span class="name">Math</span>.<span class="name">random</span>() <span class="operator">*</span> <span class="number">5000</span> <span class="operator">+</span> <span class="number">5000</span>;
<span class="name">item</span>.<span class="name">x</span> <span class="operator">=</span> <span class="name">Math</span>.<span class="name">random</span>() <span class="operator">*</span> (<span class="name">root</span>.<span class="name">width</span><span class="operator">/</span><span class="number">2</span>) <span class="operator">+</span> (<span class="name">root</span>.<span class="name">width</span><span class="operator">/</span><span class="number">2</span>);
<span class="name">item</span>.<span class="name">y</span> <span class="operator">=</span> <span class="number">0</span>;
number--;
}
}
<span class="type">Component</span> {
<span class="name">id</span>: <span class="name">fakeParticle</span>
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">id</span>: <span class="name">container</span>
property <span class="type">int</span> <span class="name">lifeSpan</span>: <span class="number">10000</span>
<span class="name">width</span>: <span class="number">32</span>
<span class="name">height</span>: <span class="number">32</span>
<span class="name">source</span>: <span class="string">"qrc:///particleresources/glowdot.png"</span>
<span class="name">y</span>: <span class="number">0</span>
PropertyAnimation on <span class="name">y</span> {<span class="name">from</span>: -<span class="number">16</span>; <span class="name">to</span>: <span class="name">root</span>.<span class="name">height</span><span class="operator">-</span><span class="number">16</span>; <span class="name">duration</span>: <span class="name">container</span>.<span class="name">lifeSpan</span>; <span class="name">running</span>: <span class="number">true</span>}
SequentialAnimation on <span class="name">opacity</span> {
<span class="name">running</span>: <span class="number">true</span>
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></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">500</span>}
<span class="type"><a href="qml-qtquick-pauseanimation.html">PauseAnimation</a></span> { <span class="name">duration</span>: <span class="name">container</span>.<span class="name">lifeSpan</span> <span class="operator">-</span> <span class="number">1000</span>}
<span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> { <span class="name">from</span>:<span class="number">1</span>; <span class="name">to</span>: <span class="number">0</span>; <span class="name">duration</span>: <span class="number">500</span>}
<span class="type"><a href="qml-qtquick-scriptaction.html">ScriptAction</a></span> { <span class="name">script</span>: <span class="name">container</span>.<span class="name">destroy</span>(); }
}
}
}
}</pre>
<p>Note how the Image objects are not able to be randomly colorized.</p>
<p>Start and Stop simply sets the running and paused states of a <a href="qml-qtquick-particles-particlesystem.html">ParticleSystem</a>. While the system does not perform any simulation when stopped or paused, a restart restarts the simulation from the beginning, while unpausing resumes the simulation from where it was.</p>
<p>Timed group changes is an example that highlights the <a href="qml-qtquick-particles-particlegroup.html">ParticleGroup</a> type. While normally referring to groups with a string name is sufficient, additional effects can be done by setting properties on groups. The first group has a variable duration on it, but always transitions to the second group.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-particles-particlegroup.html">ParticleGroup</a></span> {
<span class="name">name</span>: <span class="string">"fire"</span>
<span class="name">duration</span>: <span class="number">2000</span>
<span class="name">durationVariation</span>: <span class="number">2000</span>
<span class="name">to</span>: {"splode":<span class="number">1</span>}
}</pre>
<p>The second group has a <a href="qml-qtquick-particles-trailemitter.html">TrailEmitter</a> on it, and a fixed duration for emitting into the third group. By placing the <a href="qml-qtquick-particles-trailemitter.html">TrailEmitter</a> as a direct child of the <a href="qml-qtquick-particles-particlegroup.html">ParticleGroup</a>, it automatically selects that group to follow.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-particles-particlegroup.html">ParticleGroup</a></span> {
<span class="name">name</span>: <span class="string">"splode"</span>
<span class="name">duration</span>: <span class="number">400</span>
<span class="name">to</span>: {"dead":<span class="number">1</span>}
<span class="type"><a href="qml-qtquick-particles-trailemitter.html">TrailEmitter</a></span> {
<span class="name">group</span>: <span class="string">"works"</span>
<span class="name">emitRatePerParticle</span>: <span class="number">100</span>
<span class="name">lifeSpan</span>: <span class="number">1000</span>
<span class="name">maximumEmitted</span>: <span class="number">1200</span>
<span class="name">size</span>: <span class="number">8</span>
<span class="name">velocity</span>: <span class="name">AngleDirection</span> {<span class="name">angle</span>: <span class="number">270</span>; <span class="name">angleVariation</span>: <span class="number">45</span>; <span class="name">magnitude</span>: <span class="number">20</span>; <span class="name">magnitudeVariation</span>: <span class="number">20</span>;}
<span class="name">acceleration</span>: <span class="name">PointDirection</span> {<span class="name">y</span>:<span class="number">100</span>; <span class="name">yVariation</span>: <span class="number">20</span>}
}
}</pre>
<p>The third group has an Affector as a direct child, which makes the affector automatically target this group. The affector means that as soon as particles enter this group, a burst function can be called on another emitter, using the x,y positions of this particle.</p>
<pre class="qml"><span class="type"><a href="qml-qtquick-particles-particlegroup.html">ParticleGroup</a></span> {
<span class="name">name</span>: <span class="string">"dead"</span>
<span class="name">duration</span>: <span class="number">1000</span>
<span class="type"><a href="qml-qtquick-particles-affector.html">Affector</a></span> {
<span class="name">once</span>: <span class="number">true</span>
<span class="name">onAffected</span>: <span class="name">worksEmitter</span>.<span class="name">burst</span>(<span class="number">400</span>,<span class="name">x</span>,<span class="name">y</span>)
}
}</pre>
<p>If <a href="qml-qtquick-particles-trailemitter.html">TrailEmitter</a> does not suit your needs for multiple emitters, you can also dynamically create Emitters while still using the same <a href="qml-qtquick-particles-particlesystem.html">ParticleSystem</a> and image particle</p>
<pre class="qml"><span class="keyword">for</span> (<span class="keyword">var</span> <span class="name">i</span>=<span class="number">0</span>; <span class="name">i</span><span class="operator"><</span><span class="number">8</span>; i++) {
var <span class="name">obj</span> = <span class="name">emitterComp</span>.<span class="name">createObject</span>(<span class="name">root</span>);
<span class="name">obj</span>.<span class="name">x</span> <span class="operator">=</span> <span class="name">x</span>
<span class="name">obj</span>.<span class="name">y</span> <span class="operator">=</span> <span class="name">y</span>
<span class="name">obj</span>.<span class="name">targetX</span> <span class="operator">=</span> <span class="name">Math</span>.<span class="name">random</span>() <span class="operator">*</span> <span class="number">240</span> <span class="operator">-</span> <span class="number">120</span> <span class="operator">+</span> <span class="name">obj</span>.<span class="name">x</span>
<span class="name">obj</span>.<span class="name">targetY</span> <span class="operator">=</span> <span class="name">Math</span>.<span class="name">random</span>() <span class="operator">*</span> <span class="number">240</span> <span class="operator">-</span> <span class="number">120</span> <span class="operator">+</span> <span class="name">obj</span>.<span class="name">y</span>
<span class="name">obj</span>.<span class="name">life</span> <span class="operator">=</span> <span class="name">Math</span>.<span class="name">round</span>(<span class="name">Math</span>.<span class="name">random</span>() <span class="operator">*</span> <span class="number">2400</span>) <span class="operator">+</span> <span class="number">200</span>
<span class="name">obj</span>.<span class="name">emitRate</span> <span class="operator">=</span> <span class="name">Math</span>.<span class="name">round</span>(<span class="name">Math</span>.<span class="name">random</span>() <span class="operator">*</span> <span class="number">32</span>) <span class="operator">+</span> <span class="number">32</span>
<span class="name">obj</span>.<span class="name">go</span>();
}</pre>
<p>Note that this effect, a flurry of flying rainbow spears, would be better served with <a href="qml-qtquick-particles-trailemitter.html">TrailEmitter</a>. It is only done with dynamic emitters in this example to show the concept more simply.</p>
<p>Multiple Painters shows how to control paint ordering of individual particles. While the paint ordering of particles within one ImagePainter is not strictly defined, <a href="qml-qtquick-particles-imageparticle.html">ImageParticle</a> objects follow the normal Z-ordering rules for <a href="qtquick-index.html">Qt Quick</a> items. This example allow you to paint the inside of the particles above the black borders using a pair of ImageParticles each painting different parts of the same logical particle.</p>
<p>Files:</p>
<ul>
<li><a href="qtquick-particles-system-system-qml.html">particles/system/system.qml</a></li>
<li><a href="qtquick-particles-system-content-dynamiccomparison-qml.html">particles/system/content/dynamiccomparison.qml</a></li>
<li><a href="qtquick-particles-system-content-dynamicemitters-qml.html">particles/system/content/dynamicemitters.qml</a></li>
<li><a href="qtquick-particles-system-content-multiplepainters-qml.html">particles/system/content/multiplepainters.qml</a></li>
<li><a href="qtquick-particles-system-content-startstop-qml.html">particles/system/content/startstop.qml</a></li>
<li><a href="qtquick-particles-system-content-timedgroupchanges-qml.html">particles/system/content/timedgroupchanges.qml</a></li>
<li><a href="qtquick-particles-system-main-cpp.html">particles/system/main.cpp</a></li>
<li><a href="qtquick-particles-system-system-pro.html">particles/system/system.pro</a></li>
<li><a href="qtquick-particles-system-system-qmlproject.html">particles/system/system.qmlproject</a></li>
<li><a href="qtquick-particles-system-system-qrc.html">particles/system/system.qrc</a></li>
</ul>
</div>
<!-- @@@particles/system -->
</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>
|