aboutsummaryrefslogtreecommitdiffstats
path: root/examples/particles
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2012-06-18 14:13:31 +1000
committerQt by Nokia <qt-info@nokia.com>2012-06-29 04:05:44 +0200
commitf4e75e134f5712156ad2b720b48265da683dda94 (patch)
treed521ea46a3222f6e31f5e646b8dc35b7125e6abc /examples/particles
parent5df94d89033e7bbb3f41840a4c07a628ed66b4d5 (diff)
Update particles examples en masse
Change-Id: I882f59c687d790bc55cf59abf6f0ea80b65b50d9 Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'examples/particles')
-rw-r--r--examples/particles/customparticle/content/blurparticles.qml (renamed from examples/particles/customparticle/blurparticles.qml)6
-rw-r--r--examples/particles/customparticle/content/fragmentshader.qml (renamed from examples/particles/customparticle/fragmentshader.qml)11
-rw-r--r--examples/particles/customparticle/content/imagecolors.qml (renamed from examples/particles/customparticle/imagecolors.qml)14
-rw-r--r--examples/particles/customparticle/customparticle.pro10
-rw-r--r--examples/particles/customparticle/customparticle.qml84
-rw-r--r--examples/particles/customparticle/customparticle.qmlproject16
-rw-r--r--examples/particles/customparticle/main.cpp41
-rw-r--r--examples/particles/emitters/content/burstandpulse.qml (renamed from examples/particles/emitters/burstandpulse.qml)88
-rw-r--r--examples/particles/emitters/content/customemitter.qml (renamed from examples/particles/emitters/customemitter.qml)6
-rw-r--r--examples/particles/emitters/content/emitmask.qml (renamed from examples/particles/emitters/emitmask.qml)6
-rw-r--r--examples/particles/emitters/content/maximumemitted.qml (renamed from examples/particles/emitters/maximumemitted.qml)2
-rw-r--r--examples/particles/emitters/content/shapeanddirection.qml (renamed from examples/particles/emitters/shapeanddirection.qml)6
-rw-r--r--examples/particles/emitters/content/trailemitter.qml (renamed from examples/particles/emitters/trailemitter.qml)4
-rw-r--r--examples/particles/emitters/content/velocityfrommotion.qml (renamed from examples/particles/emitters/velocityfrommotion.qml)11
-rw-r--r--examples/particles/emitters/emitters.pro10
-rw-r--r--examples/particles/emitters/emitters.qml95
-rw-r--r--examples/particles/emitters/emitters.qmlproject16
-rw-r--r--examples/particles/emitters/main.cpp41
-rw-r--r--examples/particles/imageparticle/content/allatonce.qml (renamed from examples/particles/imageparticle/allatonce.qml)6
-rw-r--r--examples/particles/imageparticle/content/colored.qml (renamed from examples/particles/imageparticle/colored.qml)6
-rw-r--r--examples/particles/imageparticle/content/colortable.qml (renamed from examples/particles/imageparticle/colortable.qml)8
-rw-r--r--examples/particles/imageparticle/content/deformation.qml (renamed from examples/particles/imageparticle/deformation.qml)8
-rw-r--r--examples/particles/imageparticle/content/rotation.qml (renamed from examples/particles/imageparticle/rotation.qml)4
-rw-r--r--examples/particles/imageparticle/content/sharing.qml (renamed from examples/particles/imageparticle/sharing.qml)8
-rw-r--r--examples/particles/imageparticle/content/sprites.qml (renamed from examples/particles/imageparticle/sprites.qml)10
-rw-r--r--examples/particles/imageparticle/imageparticle.pro10
-rw-r--r--examples/particles/imageparticle/imageparticle.qml96
-rw-r--r--examples/particles/imageparticle/imageparticle.qmlproject16
-rw-r--r--examples/particles/imageparticle/main.cpp41
-rw-r--r--examples/particles/particles.pro10
-rw-r--r--examples/particles/system/content/dynamiccomparison.qml (renamed from examples/particles/simple/dynamiccomparison.qml)21
-rw-r--r--examples/particles/system/content/dynamicemitters.qml (renamed from examples/particles/simple/dynamicemitters.qml)44
-rw-r--r--examples/particles/system/content/multiplepainters.qml (renamed from examples/particles/simple/multiplepainters.qml)12
-rw-r--r--examples/particles/system/content/startstop.qml (renamed from examples/particles/simple/startstop.qml)9
-rw-r--r--examples/particles/system/content/timedgroupchanges.qml (renamed from examples/particles/emitters/timedgroupchanges.qml)8
-rw-r--r--examples/particles/system/main.cpp41
-rw-r--r--examples/particles/system/system.pro10
-rw-r--r--examples/particles/system/system.qml90
-rw-r--r--examples/particles/system/system.qmlproject16
39 files changed, 847 insertions, 94 deletions
diff --git a/examples/particles/customparticle/blurparticles.qml b/examples/particles/customparticle/content/blurparticles.qml
index 9b432e093d..c1ad03b04b 100644
--- a/examples/particles/customparticle/blurparticles.qml
+++ b/examples/particles/customparticle/content/blurparticles.qml
@@ -63,11 +63,12 @@ Rectangle {
}
Image {
id: theItem
- source: "../images/starfish_1.png"
+ source: "../../images/starfish_1.png"
}
CustomParticle {
system: sys
+ //! [vertex]
vertexShader:"
uniform lowp float qt_Opacity;
varying lowp float fFade;
@@ -83,6 +84,7 @@ Rectangle {
fBlur = max(0.2 * t, t * qt_ParticleR);
}
"
+ //! [vertex]
property variant source: theSource
property variant blurred: ShaderEffectSource {
smooth: true
@@ -125,6 +127,7 @@ Rectangle {
}"
}
}
+ //! [fragment]
fragmentShader: "
uniform sampler2D source;
uniform sampler2D blurred;
@@ -134,6 +137,7 @@ Rectangle {
void main() {
gl_FragColor = mix(texture2D(source, qt_TexCoord0), texture2D(blurred, qt_TexCoord0), min(1.0,fBlur*3.0)) * fFade;
}"
+ //! [fragment]
}
}
diff --git a/examples/particles/customparticle/fragmentshader.qml b/examples/particles/customparticle/content/fragmentshader.qml
index 367cc99b7b..e2f4f92f08 100644
--- a/examples/particles/customparticle/fragmentshader.qml
+++ b/examples/particles/customparticle/content/fragmentshader.qml
@@ -43,8 +43,8 @@ import QtQuick.Particles 2.0
ParticleSystem {
id: root
- width: 1024
- height: 768
+ width: 320
+ height: 480
Rectangle {
z: -1
anchors.fill: parent
@@ -52,7 +52,7 @@ ParticleSystem {
Text {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
- font.pixelSize: 36
+ font.pixelSize: 14
color: "white"
text: "It's all in the fragment shader."
}
@@ -64,7 +64,6 @@ ParticleSystem {
size: 24
sizeVariation: 16
velocity: PointDirection {x: root.width/10; y: root.height/10;}
- //acceleration: AngledDirection {angle:225; magnitude: root.width/36; angleVariation: 45; magnitudeVariation: 80}
acceleration: PointDirection {x: -root.width/40; y: -root.height/40; xVariation: -root.width/20; yVariation: -root.width/20}
}
@@ -97,9 +96,10 @@ ParticleSystem {
highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
fFade = fadeIn * fadeOut * qt_Opacity;
- fPos = vec2(pos.x/1024., pos.y/768.);
+ fPos = vec2(pos.x/320., pos.y/480.);
}
"
+ //! [0]
fragmentShader: "
varying highp vec2 fPos;
varying lowp float fFade;
@@ -110,6 +110,7 @@ ParticleSystem {
highp float circleFactor = max(min(1.0 - dist, 1.0), 0.0);
gl_FragColor = vec4(fPos.x*2.0 - fPos.y, fPos.y*2.0 - fPos.x, fPos.x*fPos.y*2.0, 0.0) * circleFactor * fFade;
}"
+ //! [0]
}
}
diff --git a/examples/particles/customparticle/imagecolors.qml b/examples/particles/customparticle/content/imagecolors.qml
index 94e5123a0c..62345f75c1 100644
--- a/examples/particles/customparticle/imagecolors.qml
+++ b/examples/particles/customparticle/content/imagecolors.qml
@@ -62,7 +62,7 @@ Rectangle {
}
Image {
id: picture
- source: "../images/starfish_3.png"
+ source: "../../images/starfish_3.png"
}
ShaderEffectSource {
id: particleSource
@@ -71,8 +71,9 @@ Rectangle {
}
Image {
id: particle
- source: "../images/particle4.png"
+ source: "../../images/particle4.png"
}
+ //! [vertex]
vertexShader:"
uniform highp float maxWidth;
uniform highp float maxHeight;
@@ -81,14 +82,20 @@ Rectangle {
uniform lowp float qt_Opacity;
void main() {
- fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight);
+
+ fTex2 = vec2(qt_ParticlePos.x, qt_ParticlePos.y);
+ //Uncomment this next line for each particle to use full texture, instead of the solid color at the center of the particle.
+ //fTex2 = fTex2 + ((- qt_ParticleData.z / 2. + qt_ParticleData.z) * qt_ParticleTex); //Adjusts size so it's like a chunk of image.
+ fTex2 = fTex2 / vec2(maxWidth, maxHeight);
highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity;
defaultMain();
}
"
+ //! [vertex]
property variant particleTexture: particleSource
property variant pictureTexture: pictureSource
+ //! [fragment]
fragmentShader: "
uniform sampler2D particleTexture;
uniform sampler2D pictureTexture;
@@ -98,6 +105,7 @@ Rectangle {
void main() {
gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade;
}"
+ //! [fragment]
}
Emitter {
diff --git a/examples/particles/customparticle/customparticle.pro b/examples/particles/customparticle/customparticle.pro
new file mode 100644
index 0000000000..d26778f730
--- /dev/null
+++ b/examples/particles/customparticle/customparticle.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/customparticle
+qml.files = customparticle.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/customparticle
+INSTALLS += target qml
+
diff --git a/examples/particles/customparticle/customparticle.qml b/examples/particles/customparticle/customparticle.qml
new file mode 100644
index 0000000000..cb2972bc77
--- /dev/null
+++ b/examples/particles/customparticle/customparticle.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared" as Examples
+
+/*!
+ \title QtQuick.Particles Examples - CustomParticle
+ \example particles/customparticle
+ \brief This is a collection of examples using CustomParticle in the QML particle system.
+ \image qml-customparticle-example.png
+
+ This is a collection of small QML examples relating to using CustomParticle in the particle system.
+ Each example is a small QML file emphasizing a different way to use CustomParticle.
+
+ Blur Particles adds a blur effect to the particles, which increases over the particle's life time.
+ It uses a custom vertex shader:
+ \snippet examples/particles/customparticle/content/blurparticles.qml vertex
+ to propagate life time simulation to a custom fragement shader:
+ \snippet examples/particles/customparticle/content/blurparticles.qml fragment
+ which has access to both the normal image sampler and a blurred sampler, the image plus a ShaderEffect.
+
+ Fragment Shader just uses the particle system as a vertex delivery system.
+ \snippet examples/particles/customparticle/content/fragmentshader.qml 0
+
+ Image Colors uses CustomParticle to assign colors to particles based on their location in a picture.
+ The vertex shader,
+ \snippet examples/particles/customparticle/content/imagecolors.qml vertex
+ passes along the starting position for each vertex to the fragment shader,
+ \snippet examples/particles/customparticle/content/imagecolors.qml fragment
+ which uses it to determine the color for that particle.
+
+*/
+
+Item {
+ height: 480
+ width: 320
+ Examples.LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Blur Particles", "Particles that get blurred over time", Qt.resolvedUrl("content/blurparticles.qml"));
+ addExample("Fragment Shader", "Particles drawn with a custom fragment shader", Qt.resolvedUrl("content/fragmentshader.qml"));
+ addExample("Image Colors", "An image explodes into colored particles", Qt.resolvedUrl("content/imagecolors.qml"));
+ }
+ }
+}
diff --git a/examples/particles/customparticle/customparticle.qmlproject b/examples/particles/customparticle/customparticle.qmlproject
new file mode 100644
index 0000000000..6ea1849e31
--- /dev/null
+++ b/examples/particles/customparticle/customparticle.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "customparticle.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/particles/customparticle/main.cpp b/examples/particles/customparticle/main.cpp
new file mode 100644
index 0000000000..f401c36687
--- /dev/null
+++ b/examples/particles/customparticle/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(customparticle)
diff --git a/examples/particles/emitters/burstandpulse.qml b/examples/particles/emitters/content/burstandpulse.qml
index c6d39b527d..377ce9dd0e 100644
--- a/examples/particles/emitters/burstandpulse.qml
+++ b/examples/particles/emitters/content/burstandpulse.qml
@@ -42,43 +42,69 @@ import QtQuick 2.0
import QtQuick.Particles 2.0
Rectangle {
- width: 360
- height: 540
+ width: 320
+ height: 480
color: "black"
- MouseArea {
- id: ma
- anchors.fill: parent
- acceptedButtons: Qt.LeftButton | Qt.RightButton
- onClicked: {
- if (mouse.button == Qt.LeftButton)
- emitter.burst(1000);
- else
- emitter.pulse(500);
+ property bool lastWasPulse: false
+ Timer {
+ interval: 3500
+ triggeredOnStart: true
+ running: true
+ repeat: true
+ onTriggered: {
+ //! [0]
+ if (lastWasPulse) {
+ burstEmitter.burst(500);
+ lastWasPulse = false;
+ } else {
+ pulseEmitter.pulse(500);
+ lastWasPulse = true;
+ }
+ //! [0]
}
}
-
ParticleSystem {
id: particles
- }
-
- ImageParticle {
anchors.fill: parent
- system: particles
- source: "../images/star.png"
- alpha: 0
- colorVariation: 0.6
- }
+ ImageParticle {
+ source: "../../images/star.png"
+ alpha: 0
+ colorVariation: 0.6
+ }
- Emitter {
- id: emitter
- x: ma.mouseX
- y: ma.mouseY
- system: particles
- emitRate: 2000
- lifeSpan: 2000
- enabled: false
- velocity: AngleDirection{magnitude: 64; angleVariation: 360}
- size: 24
- sizeVariation: 8
+ Emitter {
+ id: burstEmitter
+ x: parent.width/2
+ y: parent.height/3
+ emitRate: 1000
+ lifeSpan: 2000
+ enabled: false
+ velocity: AngleDirection{magnitude: 64; angleVariation: 360}
+ size: 24
+ sizeVariation: 8
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 18
+ text: "Burst"
+ }
+ }
+ Emitter {
+ id: pulseEmitter
+ x: parent.width/2
+ y: 2*parent.height/3
+ emitRate: 1000
+ lifeSpan: 2000
+ enabled: false
+ velocity: AngleDirection{magnitude: 64; angleVariation: 360}
+ size: 24
+ sizeVariation: 8
+ Text {
+ anchors.centerIn: parent
+ color: "white"
+ font.pixelSize: 18
+ text: "Pulse"
+ }
+ }
}
}
diff --git a/examples/particles/emitters/customemitter.qml b/examples/particles/emitters/content/customemitter.qml
index 135b3d781c..baa513ba11 100644
--- a/examples/particles/emitters/customemitter.qml
+++ b/examples/particles/emitters/content/customemitter.qml
@@ -68,6 +68,7 @@ ParticleSystem {
emitRate: 120
size: 12
anchors.centerIn: parent
+ //! [0]
onEmitParticles: {
for (var i=0; i<particles.length; i++) {
var particle = particles[i];
@@ -78,17 +79,18 @@ ParticleSystem {
particle.blue = theta == 4 || theta == 5 || theta == 0 ? 0.2 : 1;
theta /= 6.0;
theta *= 2.0*Math.PI;
- theta += sys.convert(sys.petalRotation);
+ theta += sys.convert(sys.petalRotation);//Convert from degrees to radians
particle.initialVX = petalLength * Math.cos(theta);
particle.initialVY = petalLength * Math.sin(theta);
particle.initialAX = particle.initialVX * -0.5;
particle.initialAY = particle.initialVY * -0.5;
}
}
+ //! [0]
}
ImageParticle {
- source: "../images/particle4.png"
+ source: "../../images/particle4.png"
alpha: 0.0
}
}
diff --git a/examples/particles/emitters/emitmask.qml b/examples/particles/emitters/content/emitmask.qml
index 9c02f6a213..ba39fe2035 100644
--- a/examples/particles/emitters/emitmask.qml
+++ b/examples/particles/emitters/content/emitmask.qml
@@ -51,7 +51,7 @@ Rectangle {
anchors.centerIn: parent
ImageParticle {
- source: "../images/particle.png"
+ source: "../../images/particle.png"
z: 2
anchors.fill: parent
color: "#336666CC"
@@ -63,9 +63,11 @@ Rectangle {
emitRate: 6000
lifeSpan: 720
size: 10
+ //! [0]
shape: MaskShape {
- source: "../images/starfish_mask.png"
+ source: "../../images/starfish_mask.png"
}
+ //! [0]
}
}
diff --git a/examples/particles/emitters/maximumemitted.qml b/examples/particles/emitters/content/maximumemitted.qml
index 6dbdf8db61..b99814ce88 100644
--- a/examples/particles/emitters/maximumemitted.qml
+++ b/examples/particles/emitters/content/maximumemitted.qml
@@ -53,7 +53,7 @@ Rectangle {
ImageParticle {
system: sys
id: cp
- source: "../images/particle.png"
+ source: "../../images/particle.png"
colorVariation: 0.4
color: "#000000FF"
}
diff --git a/examples/particles/emitters/shapeanddirection.qml b/examples/particles/emitters/content/shapeanddirection.qml
index 3d378b8492..d2a8bb1dd5 100644
--- a/examples/particles/emitters/shapeanddirection.qml
+++ b/examples/particles/emitters/content/shapeanddirection.qml
@@ -48,7 +48,7 @@ Rectangle {
color: "black"
Image {
anchors.fill: parent
- source: "../images/portal_bg.png"
+ source: "../../images/portal_bg.png"
}
ParticleSystem {
@@ -59,7 +59,7 @@ Rectangle {
groups: ["center","edge"]
anchors.fill: parent
system: particles
- source: "../images/particle.png"
+ source: "../../images/particle.png"
colorVariation: 0.1
color: "#009999FF"
}
@@ -73,6 +73,7 @@ Rectangle {
size: 20
sizeVariation: 2
endSize: 0
+ //! [0]
shape: EllipseShape {fill: false}
velocity: TargetDirection {
targetX: root.width/2
@@ -80,6 +81,7 @@ Rectangle {
proportionalMagnitude: true
magnitude: 0.5
}
+ //! [0]
}
Emitter {
diff --git a/examples/particles/emitters/trailemitter.qml b/examples/particles/emitters/content/trailemitter.qml
index 83b46e2d70..b225b59d6a 100644
--- a/examples/particles/emitters/trailemitter.qml
+++ b/examples/particles/emitters/content/trailemitter.qml
@@ -56,7 +56,7 @@ Rectangle {
system: particles
anchors.fill: parent
groups: ["A", "B"]
- source: "../images/particle.png"
+ source: "../../images/particle.png"
colorVariation: 0
color: "#00111111"
}
@@ -65,7 +65,7 @@ Rectangle {
anchors.fill: parent
system: particles
groups: ["C", "D"]
- source: "../images/particle.png"
+ source: "../../images/particle.png"
colorVariation: 0.1
color: "#00ff400f"
}
diff --git a/examples/particles/emitters/velocityfrommotion.qml b/examples/particles/emitters/content/velocityfrommotion.qml
index ffca3c11b2..27afbc952c 100644
--- a/examples/particles/emitters/velocityfrommotion.qml
+++ b/examples/particles/emitters/content/velocityfrommotion.qml
@@ -61,7 +61,7 @@ Rectangle {
ParticleSystem { id: sys1 }
ImageParticle {
system: sys1
- source: "../images/particle.png"
+ source: "../../images/particle.png"
color: "cyan"
alpha: 0
SequentialAnimation on color {
@@ -89,6 +89,7 @@ Rectangle {
}
colorVariation: 0.3
}
+ //! [0]
Emitter {
id: trailsNormal
system: sys1
@@ -96,7 +97,6 @@ Rectangle {
emitRate: 500
lifeSpan: 2000
-
y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
x: mouseArea.pressed ? mouseArea.mouseX : circle.cx
@@ -107,6 +107,7 @@ Rectangle {
size: 8
sizeVariation: 4
}
+ //! [0]
ParticleSystem { id: sys2 }
ImageParticle {
color: "cyan"
@@ -126,7 +127,7 @@ Rectangle {
}
}
colorVariation: 0.5
- source: "../images/star.png"
+ source: "../../images/star.png"
}
Emitter {
id: trailsStars
@@ -148,7 +149,7 @@ Rectangle {
}
ParticleSystem { id: sys3; }
ImageParticle {
- source: "../images/particle.png"
+ source: "../../images/particle.png"
system: sys3
color: "orange"
alpha: 0
@@ -190,7 +191,7 @@ Rectangle {
ParticleSystem { id: sys4; }
ImageParticle {
system: sys4
- source: "../images/star.png"
+ source: "../../images/star.png"
color: "green"
alpha: 0
SequentialAnimation on color {
diff --git a/examples/particles/emitters/emitters.pro b/examples/particles/emitters/emitters.pro
new file mode 100644
index 0000000000..7147d716ad
--- /dev/null
+++ b/examples/particles/emitters/emitters.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/emitters
+qml.files = emitters.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/emitters
+INSTALLS += target qml
+
diff --git a/examples/particles/emitters/emitters.qml b/examples/particles/emitters/emitters.qml
new file mode 100644
index 0000000000..d6537569cf
--- /dev/null
+++ b/examples/particles/emitters/emitters.qml
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared" as Examples
+
+/*!
+ \title QtQuick.Particles Examples - Emitters
+ \example particles/emitters
+ \brief This is a collection of examples using Emitters in the QML particle system.
+ \image qml-emitters-example.png
+
+ This is a collection of small QML examples relating to using Emitters in the particle system.
+ Each example is a small QML file emphasizing a particular element or feature.
+
+ Velocity from motion gives the effect of strong particle motion through primarily moving the emitters:
+ \snippet examples/particles/emitters/content/velocityfrommotion.qml 0
+
+ Burst and pulse calls the burst and pulse methods on two idential emitters.
+ \snippet examples/particles/emitters/content/burstandpulse.qml 0
+ Note how burst takes an argument of number of particles to emit, and pulse takes an argument of number of milliseconds to emit for.
+ This gives a slightly different behaviour, which is easy to see in this example.
+
+ Custom Emitter connects to the emitParticles signal to set arbitrary values on particle data as they're emitted;
+ \snippet examples/particles/emitters/content/customemitter.qml 0
+ This is used to emit curving particles in six rotating spokes.
+
+ Emit mask sets an image mask on the Emitter, to emit out of an arbitrary shape.
+ \snippet examples/particles/emitters/content/emitmask.qml 0
+
+ Maximum emitted emits no more than a certain number of particles at a time. This example makes it easy to see what happens when the limit is reached.
+
+ Shape and Direction emits particles out of an unfilled Ellipse shape, using a TargetDirection
+ \snippet examples/particles/emitters/content/shapeanddirection.qml 0
+ This sends the particles towards the center of the ellipse with proportional speed, keeping the ellipse outline as they move to the center.
+
+ TrailEmitter uses that element to add smoke particles to trail the fire particles in the scene.
+ \snippet examples/particles/emitters/content/trailemitter.qml 0
+
+*/
+
+Item {
+ height: 480
+ width: 320
+ Examples.LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Velocity from Motion", "Particle motion just by moving emitters", Qt.resolvedUrl("content/velocityfrommotion.qml"));
+ addExample("Burst and Pulse", "Emit imperatively", Qt.resolvedUrl("content/burstandpulse.qml"));
+ addExample("Custom Emitter", "Custom starting state", Qt.resolvedUrl("content/customemitter.qml"));
+ addExample("Emit Mask", "Emit arbitrary shapes", Qt.resolvedUrl("content/emitmask.qml"));
+ addExample("Maximum Emitted", "Put a limit on emissions", Qt.resolvedUrl("content/maximumemitted.qml"));
+ addExample("Shape and Direction", "Creates a portal effect", Qt.resolvedUrl("content/shapeanddirection.qml"));
+ addExample("TrailEmitter", "Emit from other particles", Qt.resolvedUrl("content/trailemitter.qml"));
+ }
+ }
+}
diff --git a/examples/particles/emitters/emitters.qmlproject b/examples/particles/emitters/emitters.qmlproject
new file mode 100644
index 0000000000..5379aac1dc
--- /dev/null
+++ b/examples/particles/emitters/emitters.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "emitters.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/particles/emitters/main.cpp b/examples/particles/emitters/main.cpp
new file mode 100644
index 0000000000..e75cbe4b53
--- /dev/null
+++ b/examples/particles/emitters/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(emitters)
diff --git a/examples/particles/imageparticle/allatonce.qml b/examples/particles/imageparticle/content/allatonce.qml
index cedc17d7aa..a417e62e5b 100644
--- a/examples/particles/imageparticle/allatonce.qml
+++ b/examples/particles/imageparticle/content/allatonce.qml
@@ -50,18 +50,20 @@ Rectangle {
}
ImageParticle {
+ // ![0]
sprites: [
Sprite {
name: "bear"
- source: "../images/bear_tiles.png"
+ source: "../../images/bear_tiles.png"
frameCount: 13
frameDuration: 120
}
]
colorVariation: 0.5
rotationVelocityVariation: 360
+ colorTable: "../../images/colortable.png"
+ // ![0]
system: sys
- colorTable: "../trails/../images/colortable.png"
}
Friction {
diff --git a/examples/particles/imageparticle/colored.qml b/examples/particles/imageparticle/content/colored.qml
index 8ae9a8e0bc..2a9ccd779a 100644
--- a/examples/particles/imageparticle/colored.qml
+++ b/examples/particles/imageparticle/content/colored.qml
@@ -50,7 +50,7 @@ Rectangle {
ImageParticle {
groups: ["stars"]
anchors.fill: parent
- source: "../images/star.png"
+ source: "../../images/star.png"
}
Emitter {
group: "stars"
@@ -61,13 +61,15 @@ Rectangle {
anchors.fill: parent
}
+ // ![0]
ImageParticle {
anchors.fill: parent
- source: "../images/star.png"
+ source: "../../images/star.png"
alpha: 0
alphaVariation: 0.2
colorVariation: 1.0
}
+ // ![0]
Emitter {
anchors.centerIn: parent
diff --git a/examples/particles/imageparticle/colortable.qml b/examples/particles/imageparticle/content/colortable.qml
index e7c9b5c176..5b8fbf2316 100644
--- a/examples/particles/imageparticle/colortable.qml
+++ b/examples/particles/imageparticle/content/colortable.qml
@@ -54,9 +54,11 @@ Rectangle {
colorVariation: 0.5
alpha: 0
- source: "../images/particle.png"
- colorTable: "../images/colortable.png"
- sizeTable: "../images/colortable.png"
+ //! [0]
+ source: "../../images/particle.png"
+ colorTable: "../../images/colortable.png"
+ sizeTable: "../../images/colortable.png"
+ //! [0]
}
Emitter {
diff --git a/examples/particles/imageparticle/deformation.qml b/examples/particles/imageparticle/content/deformation.qml
index 0fca37e3e1..ea3f741159 100644
--- a/examples/particles/imageparticle/deformation.qml
+++ b/examples/particles/imageparticle/content/deformation.qml
@@ -47,21 +47,25 @@ Rectangle {
height: 400
ParticleSystem {id:sys}
+ //! [spin]
ImageParticle {
system: sys
groups: ["goingLeft", "goingRight"]
- source: "../images/starfish_4.png"
+ source: "../../images/starfish_4.png"
rotation: 90
rotationVelocity: 90
autoRotation: true
}
+ //! [spin]
+ //! [deform]
ImageParticle {
system: sys
groups: ["goingDown"]
- source: "../images/starfish_0.png"
+ source: "../../images/starfish_0.png"
rotation: 180
yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; }
}
+ //! [deform]
Timer {
running: true
diff --git a/examples/particles/imageparticle/rotation.qml b/examples/particles/imageparticle/content/rotation.qml
index 34e063b1f5..4f95fa23b8 100644
--- a/examples/particles/imageparticle/rotation.qml
+++ b/examples/particles/imageparticle/content/rotation.qml
@@ -49,7 +49,9 @@ Rectangle {
ImageParticle {
id: up
system: sys
- source: "../images/starfish_2.png"
+ source: "../../images/starfish_2.png"
+ autoRotation: true //leaving these two settings at default allows you to test going up performance levels
+ rotation: -90
}
Emitter {
diff --git a/examples/particles/imageparticle/sharing.qml b/examples/particles/imageparticle/content/sharing.qml
index d1a516fc49..3fe50c8a2c 100644
--- a/examples/particles/imageparticle/sharing.qml
+++ b/examples/particles/imageparticle/content/sharing.qml
@@ -90,14 +90,16 @@ Rectangle {
}
y: listView.currentItem.y;
Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
+ //! [1]
ImageParticle {
anchors.fill: parent
system: particles
- source: "../images/flower.png"
+ source: "../../images/flower.png"
color: "red"
clip: true
alpha: 1.0
}
+ //! [1]
}
}
@@ -127,15 +129,17 @@ Rectangle {
startTime: 5000
}
+ //! [0]
ImageParticle {
anchors.fill: parent
system: particles
- source: "../images/flower.png"
+ source: "../../images/flower.png"
alpha: 0.1
color: "white"
rotationVariation: 180
z: -1
}
+ //! [0]
}
ListModel {
diff --git a/examples/particles/imageparticle/sprites.qml b/examples/particles/imageparticle/content/sprites.qml
index 1e5aaa0f75..2f5baaf002 100644
--- a/examples/particles/imageparticle/sprites.qml
+++ b/examples/particles/imageparticle/content/sprites.qml
@@ -50,7 +50,7 @@ Rectangle {
SpriteSequence {
sprites: Sprite {
name: "bear"
- source: "../images/bear_tiles.png"
+ source: "../../images/bear_tiles.png"
frameCount: 13
frameDuration: 120
}
@@ -70,25 +70,25 @@ Rectangle {
system: sys
sprites: [Sprite {
name: "happy"
- source: "../images/starfish_1.png"
+ source: "../../images/starfish_1.png"
frameCount: 1
frameDuration: 260
to: {"happy": 1, "silly": 1, "angry": 1}
}, Sprite {
name: "angry"
- source: "../images/starfish_0.png"
+ source: "../../images/starfish_0.png"
frameCount: 1
frameDuration: 260
to: {"happy": 1, "silly": 1, "angry": 1}
}, Sprite {
name: "silly"
- source: "../images/starfish_2.png"
+ source: "../../images/starfish_2.png"
frameCount: 1
frameDuration: 260
to: {"happy": 1, "silly": 1, "noticedbear": 0}
}, Sprite {
name: "noticedbear"
- source: "../images/starfish_3.png"
+ source: "../../images/starfish_3.png"
frameCount: 1
frameDuration: 2600
}]
diff --git a/examples/particles/imageparticle/imageparticle.pro b/examples/particles/imageparticle/imageparticle.pro
new file mode 100644
index 0000000000..8d5b06cc89
--- /dev/null
+++ b/examples/particles/imageparticle/imageparticle.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/imageparticle
+qml.files = imageparticle.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/imageparticle
+INSTALLS += target qml
+
diff --git a/examples/particles/imageparticle/imageparticle.qml b/examples/particles/imageparticle/imageparticle.qml
new file mode 100644
index 0000000000..c6c9ace02e
--- /dev/null
+++ b/examples/particles/imageparticle/imageparticle.qml
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared" as Examples
+
+/*!
+ \title QtQuick.Particles Examples - Affectors
+ \example particles/imageparticle
+ \brief This is a collection of examples using Affectors in the QML particle system.
+ \image qml-imageparticle-example.png
+
+ 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 element or feature.
+
+ All at once shows off several of the features of ImageParticle at the same time.
+ \snippet examples/particles/imageparticle/content/allatonce.qml 0
+
+ Colored shows a simple ImageParticle with some color variation.
+ \snippet examples/particles/imageparticle/content/colored.qml 0
+
+ Color Table sets the color over life on the particles to provide a fixed rainbow effect.
+ \snippet examples/particles/imageparticle/content/colortable.qml 0
+
+ Deformation spins and squishes a starfish particle.
+ \snippet examples/particles/imageparticle/content/colortable.qml spin
+ \snippet examples/particles/imageparticle/content/colortable.qml deform
+
+ Rotation demonstrates the autoRotate property, so that particles rotate in the direction that they travel.
+
+ Sharing demonstrates what happens when multiple ImageParticles try to render the same particle.
+ The following ImageParticle renders the particles inside the ListView:
+ \snippet examples/particles/imageparticle/content/sharing.qml 0
+ The following ImageParticle is placed inside the list highlight, and renders the particles above the other ImageParticle.
+ \snippet examples/particles/imageparticle/content/sharing.qml 1
+ Note that because it sets the color and alpha in this ImageParticle, it renders the particles in a different color.
+ Since it doesn't specify anything about the rotation, it shares the rotation with the other ImageParticle so that the flowers are rotated the same way in both.
+ Note that you can undo rotation in another ImageParticle, you just need to explicity set rotationVariation to 0.
+
+ Sprites demonstrates using an image particle to render animated sprites instead of static images for each particle.
+*/
+
+Item {
+ height: 480
+ width: 320
+ Examples.LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("All at once", "Uses all ImageParticle features", Qt.resolvedUrl("content/allatonce.qml"));
+ addExample("Colored", "Colorized image particles", Qt.resolvedUrl("content/colored.qml"));
+ addExample("Color Table", "Color-over-life rainbow particles", Qt.resolvedUrl("content/colortable.qml"));
+ addExample("Deformation", "Deformed particles", Qt.resolvedUrl("content/deformation.qml"));
+ addExample("Rotation", "Rotated particles", Qt.resolvedUrl("content/rotation.qml"));
+ addExample("Sharing", "Multiple ImageParticles on the same particles", Qt.resolvedUrl("content/sharing.qml"));
+ addExample("Sprites", "Partiles rendered with sprites", Qt.resolvedUrl("content/sprites.qml"));
+ }
+ }
+}
diff --git a/examples/particles/imageparticle/imageparticle.qmlproject b/examples/particles/imageparticle/imageparticle.qmlproject
new file mode 100644
index 0000000000..902cf6519a
--- /dev/null
+++ b/examples/particles/imageparticle/imageparticle.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "imageparticle.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/particles/imageparticle/main.cpp b/examples/particles/imageparticle/main.cpp
new file mode 100644
index 0000000000..96f9145cd1
--- /dev/null
+++ b/examples/particles/imageparticle/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(imageparticle)
diff --git a/examples/particles/particles.pro b/examples/particles/particles.pro
index 967108504e..385da36a08 100644
--- a/examples/particles/particles.pro
+++ b/examples/particles/particles.pro
@@ -1 +1,11 @@
TEMPLATE = subdirs
+SUBDIRS += affectors \
+ customparticle \
+ emitters \
+ imageparticle \
+ system
+
+#Install shared images too
+qml.files = images
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles
+INSTALLS = qml
diff --git a/examples/particles/simple/dynamiccomparison.qml b/examples/particles/system/content/dynamiccomparison.qml
index d244e0e770..5084aea25c 100644
--- a/examples/particles/simple/dynamiccomparison.qml
+++ b/examples/particles/system/content/dynamiccomparison.qml
@@ -52,7 +52,7 @@ Rectangle {
ImageParticle {
system: sys
- source: "../images/particle.png"
+ source: "../../images/particle.png"
color: "white"
colorVariation: 1.0
alpha: 0.1
@@ -70,13 +70,14 @@ Rectangle {
size: 32
}
+ //! [fake]
Item {
id: fakeEmitter
function burst(number) {
while (number > 0) {
var item = fakeParticle.createObject(root);
item.lifeSpan = Math.random() * 5000 + 5000;
- item.x = Math.random() * 320 + 320;
+ item.x = Math.random() * (root.width/2) + (root.width/2);
item.y = 0;
number--;
}
@@ -89,9 +90,9 @@ Rectangle {
property int lifeSpan: 10000
width: 32
height: 32
- source: "../images/particle.png"
+ source: "../../images/particle.png"
y: 0
- PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true}
+ PropertyAnimation on y {from: -16; to: root.height-16; duration: container.lifeSpan; running: true}
SequentialAnimation on opacity {
running: true
NumberAnimation { from:0; to: 1; duration: 500}
@@ -102,7 +103,19 @@ Rectangle {
}
}
}
+ //! [fake]
+ //Hooked to a timer, but click for extra bursts that really stress performance
+ Timer {
+ interval: 10000
+ triggeredOnStart: true
+ repeat: true
+ running: true
+ onTriggered: {
+ emitter.burst(1000);
+ fakeEmitter.burst(1000);
+ }
+ }
Text {
anchors.left: parent.left
anchors.bottom: parent.bottom
diff --git a/examples/particles/simple/dynamicemitters.qml b/examples/particles/system/content/dynamicemitters.qml
index 8f007f3fdc..5fa4960109 100644
--- a/examples/particles/simple/dynamicemitters.qml
+++ b/examples/particles/system/content/dynamicemitters.qml
@@ -51,7 +51,7 @@ Rectangle {
}
ImageParticle {
system: sys
- source: "../images/particle.png"
+ source: "../../images/particle.png"
color: "white"
colorVariation: 1.0
alpha: 0.1
@@ -104,19 +104,37 @@ Rectangle {
}
}
+ function customEmit(x,y) {
+ //! [0]
+ for (var i=0; i<8; i++) {
+ var obj = emitterComp.createObject(root);
+ obj.x = x
+ obj.y = y
+ obj.targetX = Math.random() * 240 - 120 + obj.x
+ obj.targetY = Math.random() * 240 - 120 + obj.y
+ obj.life = Math.round(Math.random() * 2400) + 200
+ obj.emitRate = Math.round(Math.random() * 32) + 32
+ obj.go();
+ }
+ //! [0]
+ }
+
+ Timer {
+ interval: 10000
+ triggeredOnStart: true
+ running: true
+ repeat: true
+ onTriggered: customEmit(Math.random() * 320, Math.random() * 480)
+ }
MouseArea {
anchors.fill: parent
- onClicked: {
- for (var i=0; i<8; i++) {
- var obj = emitterComp.createObject(root);
- obj.x = mouse.x
- obj.y = mouse.y
- obj.targetX = Math.random() * 240 - 120 + obj.x
- obj.targetY = Math.random() * 240 - 120 + obj.y
- obj.life = Math.round(Math.random() * 2400) + 200
- obj.emitRate = Math.round(Math.random() * 32) + 32
- obj.go();
- }
- }
+ onClicked: customEmit(mouse.x, mouse.y);
+ }
+
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Click Somewhere"
+ color: "white"
+ font.pixelSize: 24
}
}
diff --git a/examples/particles/simple/multiplepainters.qml b/examples/particles/system/content/multiplepainters.qml
index 62a254812d..e2f9f17a82 100644
--- a/examples/particles/simple/multiplepainters.qml
+++ b/examples/particles/system/content/multiplepainters.qml
@@ -54,6 +54,12 @@ Rectangle {
anchors.fill: parent
onClicked: cloneMode = !cloneMode;
}
+ Text {
+ anchors.horizontalCenter: parent.horizontalCenter
+ text: "Click to Toggle"
+ color: "white"
+ font.pixelSize: 24
+ }
Emitter {
system: sys
y:root.height + 20
@@ -67,14 +73,14 @@ Rectangle {
ImageParticle {
system: sys
visible: !cloneMode
- source: "../images/particle2.png"
+ source: "../../images/particle2.png"
}
ImageParticle {
system: sys
visible: cloneMode
z: 0
- source: "../images/particle3.png"
+ source: "../../images/particle3.png"
}
ImageParticle {
@@ -85,6 +91,6 @@ Rectangle {
height: 240
width: root.width
z: 1
- source: "../images/particle.png"
+ source: "../../images/particle.png"
}
}
diff --git a/examples/particles/simple/startstop.qml b/examples/particles/system/content/startstop.qml
index 62105b28a0..501d206db7 100644
--- a/examples/particles/simple/startstop.qml
+++ b/examples/particles/system/content/startstop.qml
@@ -45,6 +45,11 @@ Rectangle {
width: 360
height: 540
color: "black"
+ Text {
+ text: "Left click to start/stop\nRight click to pause/unpause"
+ color: "white"
+ font.pixelSize: 24
+ }
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
@@ -64,8 +69,8 @@ Rectangle {
ImageParticle {
anchors.fill: parent
system: particles
- source: "../images/star.png"
- sizeTable: "../images/sparkleSize.png"
+ source: "../../images/star.png"
+ sizeTable: "../../images/sparkleSize.png"
alpha: 0
colorVariation: 0.6
}
diff --git a/examples/particles/emitters/timedgroupchanges.qml b/examples/particles/system/content/timedgroupchanges.qml
index 84e8cc0fa6..8d6961b965 100644
--- a/examples/particles/emitters/timedgroupchanges.qml
+++ b/examples/particles/system/content/timedgroupchanges.qml
@@ -48,12 +48,15 @@ Rectangle {
ParticleSystem {
anchors.fill: parent
id: syssy
+ //! [0]
ParticleGroup {
name: "fire"
duration: 2000
durationVariation: 2000
to: {"splode":1}
}
+ //! [0]
+ //! [1]
ParticleGroup {
name: "splode"
duration: 400
@@ -68,6 +71,8 @@ Rectangle {
acceleration: PointDirection {y:100; yVariation: 20}
}
}
+ //! [1]
+ //! [2]
ParticleGroup {
name: "dead"
duration: 1000
@@ -76,6 +81,7 @@ Rectangle {
onAffected: worksEmitter.burst(400,x,y)
}
}
+ //! [2]
Timer {
interval: 6000
@@ -113,7 +119,7 @@ Rectangle {
ImageParticle {
groups: ["works", "fire", "splode"]
- source: "../images/particle.png"
+ source: "../../images/particle.png"
entryEffect: ImageParticle.Scale
}
}
diff --git a/examples/particles/system/main.cpp b/examples/particles/system/main.cpp
new file mode 100644
index 0000000000..724d5989ae
--- /dev/null
+++ b/examples/particles/system/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(system)
diff --git a/examples/particles/system/system.pro b/examples/particles/system/system.pro
new file mode 100644
index 0000000000..613abface4
--- /dev/null
+++ b/examples/particles/system/system.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+
+target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/system
+qml.files = system.qml content
+qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/particles/system
+INSTALLS += target qml
+
diff --git a/examples/particles/system/system.qml b/examples/particles/system/system.qml
new file mode 100644
index 0000000000..acc98709ff
--- /dev/null
+++ b/examples/particles/system/system.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "../../shared" as Examples
+
+/*!
+ \title QtQuick.Particles Examples - Affectors
+ \example particles/system
+ \brief This is a collection of examples using Affectors in the QML particle system.
+ \image qml-system-example.png
+
+ 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 element or feature.
+
+ Dynamic comparison compares using the particle system to getting a similar effect with the following code that dynamically instantiates Image elements.
+ \snippet examples/particles/system/content/dynamiccomparison.qml fake
+ Note how the Image elements are not able to be randomly colorized.
+
+ Start and Stop simply sets the running and paused states of a ParticleSystem. 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.
+
+ Timed group changes is an example that highlights the ParticleGroup element. While normally referring to groups with a string name is sufficent, 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.
+ \snippet examples/particles/system/content/timedgroupchanges.qml 0
+ The second group has a TrailEmitter on it, and a fixed duration for emitting into the third group. By placing the TrailEmitter as a direct child of the ParticleGroup, it automatically selects that group to follow.
+ \snippet examples/particles/system/content/timedgroupchanges.qml 1
+ 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.
+ \snippet examples/particles/system/content/timedgroupchanges.qml 2
+
+ If TrailEmitter does not suit your needs for multiple emitters, you can also dynamically create Emitters while still using the same ParticleSystem and image particle
+ \snippet examples/particles/system/content/dynamicemitters.qml 0
+ Note that this effect, a flurry of flying rainbow spears, would be better served with TrailEmitter. It is only done with dynamic emitters in this example to show the concept more simply.
+
+ Multiple Painters shows how to control paint ordering of individual particles. While the paint ordering of particles within one ImagePainter is not strictly defined, ImageParticle elements follow the normal Z-ordering rules for QtQuick 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.
+
+*/
+
+Item {
+ height: 480
+ width: 320
+ Examples.LauncherList {
+ id: ll
+ anchors.fill: parent
+ Component.onCompleted: {
+ addExample("Dynamic Comparison", "Compares with dynamically created elements", Qt.resolvedUrl("content/dynamiccomparison.qml"));
+ addExample("StartStop", "Start and stop the simulation", Qt.resolvedUrl("content/startstop.qml"));
+ addExample("Timed group changes", "Emit into managed groups", Qt.resolvedUrl("content/timedgroupchanges.qml"));
+ addExample("Dynamic Emitters", "Dynamically instantiated emitters with a single system", Qt.resolvedUrl("content/dynamicemitters.qml"));
+ addExample("Multiple Painters", "Several ParticlePainters on the same logical particles", Qt.resolvedUrl("content/multiplepainters.qml"));
+ }
+ }
+}
diff --git a/examples/particles/system/system.qmlproject b/examples/particles/system/system.qmlproject
new file mode 100644
index 0000000000..1f9df3cecf
--- /dev/null
+++ b/examples/particles/system/system.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "system.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}