From f4e75e134f5712156ad2b720b48265da683dda94 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 18 Jun 2012 14:13:31 +1000 Subject: Update particles examples en masse Change-Id: I882f59c687d790bc55cf59abf6f0ea80b65b50d9 Reviewed-by: Alan Alpert --- .../particles/customparticle/blurparticles.qml | 140 --------- .../customparticle/content/blurparticles.qml | 144 ++++++++++ .../customparticle/content/fragmentshader.qml | 116 ++++++++ .../customparticle/content/imagecolors.qml | 126 +++++++++ .../particles/customparticle/customparticle.pro | 10 + .../particles/customparticle/customparticle.qml | 84 ++++++ .../customparticle/customparticle.qmlproject | 16 ++ .../particles/customparticle/fragmentshader.qml | 115 -------- examples/particles/customparticle/imagecolors.qml | 118 -------- examples/particles/customparticle/main.cpp | 41 +++ examples/particles/emitters/burstandpulse.qml | 84 ------ .../particles/emitters/content/burstandpulse.qml | 110 ++++++++ .../particles/emitters/content/customemitter.qml | 96 +++++++ examples/particles/emitters/content/emitmask.qml | 74 +++++ .../particles/emitters/content/maximumemitted.qml | 81 ++++++ .../emitters/content/shapeanddirection.qml | 114 ++++++++ .../particles/emitters/content/trailemitter.qml | 175 ++++++++++++ .../emitters/content/velocityfrommotion.qml | 312 +++++++++++++++++++++ examples/particles/emitters/customemitter.qml | 94 ------- examples/particles/emitters/emitmask.qml | 72 ----- examples/particles/emitters/emitters.pro | 10 + examples/particles/emitters/emitters.qml | 95 +++++++ examples/particles/emitters/emitters.qmlproject | 16 ++ examples/particles/emitters/main.cpp | 41 +++ examples/particles/emitters/maximumemitted.qml | 81 ------ examples/particles/emitters/shapeanddirection.qml | 112 -------- examples/particles/emitters/timedgroupchanges.qml | 121 -------- examples/particles/emitters/trailemitter.qml | 175 ------------ examples/particles/emitters/velocityfrommotion.qml | 311 -------------------- examples/particles/imageparticle/allatonce.qml | 98 ------- examples/particles/imageparticle/colored.qml | 86 ------ examples/particles/imageparticle/colortable.qml | 84 ------ .../particles/imageparticle/content/allatonce.qml | 100 +++++++ .../particles/imageparticle/content/colored.qml | 88 ++++++ .../particles/imageparticle/content/colortable.qml | 86 ++++++ .../imageparticle/content/deformation.qml | 125 +++++++++ .../particles/imageparticle/content/rotation.qml | 73 +++++ .../particles/imageparticle/content/sharing.qml | 203 ++++++++++++++ .../particles/imageparticle/content/sprites.qml | 116 ++++++++ examples/particles/imageparticle/deformation.qml | 121 -------- examples/particles/imageparticle/imageparticle.pro | 10 + examples/particles/imageparticle/imageparticle.qml | 96 +++++++ .../imageparticle/imageparticle.qmlproject | 16 ++ examples/particles/imageparticle/main.cpp | 41 +++ examples/particles/imageparticle/rotation.qml | 71 ----- examples/particles/imageparticle/sharing.qml | 199 ------------- examples/particles/imageparticle/sprites.qml | 116 -------- examples/particles/particles.pro | 10 + examples/particles/simple/dynamiccomparison.qml | 126 --------- examples/particles/simple/dynamicemitters.qml | 122 -------- examples/particles/simple/multiplepainters.qml | 90 ------ examples/particles/simple/startstop.qml | 81 ------ .../particles/system/content/dynamiccomparison.qml | 139 +++++++++ .../particles/system/content/dynamicemitters.qml | 140 +++++++++ .../particles/system/content/multiplepainters.qml | 96 +++++++ examples/particles/system/content/startstop.qml | 86 ++++++ .../particles/system/content/timedgroupchanges.qml | 127 +++++++++ examples/particles/system/main.cpp | 41 +++ examples/particles/system/system.pro | 10 + examples/particles/system/system.qml | 90 ++++++ examples/particles/system/system.qmlproject | 16 ++ 61 files changed, 3370 insertions(+), 2617 deletions(-) delete mode 100644 examples/particles/customparticle/blurparticles.qml create mode 100644 examples/particles/customparticle/content/blurparticles.qml create mode 100644 examples/particles/customparticle/content/fragmentshader.qml create mode 100644 examples/particles/customparticle/content/imagecolors.qml create mode 100644 examples/particles/customparticle/customparticle.pro create mode 100644 examples/particles/customparticle/customparticle.qml create mode 100644 examples/particles/customparticle/customparticle.qmlproject delete mode 100644 examples/particles/customparticle/fragmentshader.qml delete mode 100644 examples/particles/customparticle/imagecolors.qml create mode 100644 examples/particles/customparticle/main.cpp delete mode 100644 examples/particles/emitters/burstandpulse.qml create mode 100644 examples/particles/emitters/content/burstandpulse.qml create mode 100644 examples/particles/emitters/content/customemitter.qml create mode 100644 examples/particles/emitters/content/emitmask.qml create mode 100644 examples/particles/emitters/content/maximumemitted.qml create mode 100644 examples/particles/emitters/content/shapeanddirection.qml create mode 100644 examples/particles/emitters/content/trailemitter.qml create mode 100644 examples/particles/emitters/content/velocityfrommotion.qml delete mode 100644 examples/particles/emitters/customemitter.qml delete mode 100644 examples/particles/emitters/emitmask.qml create mode 100644 examples/particles/emitters/emitters.pro create mode 100644 examples/particles/emitters/emitters.qml create mode 100644 examples/particles/emitters/emitters.qmlproject create mode 100644 examples/particles/emitters/main.cpp delete mode 100644 examples/particles/emitters/maximumemitted.qml delete mode 100644 examples/particles/emitters/shapeanddirection.qml delete mode 100644 examples/particles/emitters/timedgroupchanges.qml delete mode 100644 examples/particles/emitters/trailemitter.qml delete mode 100644 examples/particles/emitters/velocityfrommotion.qml delete mode 100644 examples/particles/imageparticle/allatonce.qml delete mode 100644 examples/particles/imageparticle/colored.qml delete mode 100644 examples/particles/imageparticle/colortable.qml create mode 100644 examples/particles/imageparticle/content/allatonce.qml create mode 100644 examples/particles/imageparticle/content/colored.qml create mode 100644 examples/particles/imageparticle/content/colortable.qml create mode 100644 examples/particles/imageparticle/content/deformation.qml create mode 100644 examples/particles/imageparticle/content/rotation.qml create mode 100644 examples/particles/imageparticle/content/sharing.qml create mode 100644 examples/particles/imageparticle/content/sprites.qml delete mode 100644 examples/particles/imageparticle/deformation.qml create mode 100644 examples/particles/imageparticle/imageparticle.pro create mode 100644 examples/particles/imageparticle/imageparticle.qml create mode 100644 examples/particles/imageparticle/imageparticle.qmlproject create mode 100644 examples/particles/imageparticle/main.cpp delete mode 100644 examples/particles/imageparticle/rotation.qml delete mode 100644 examples/particles/imageparticle/sharing.qml delete mode 100644 examples/particles/imageparticle/sprites.qml delete mode 100644 examples/particles/simple/dynamiccomparison.qml delete mode 100644 examples/particles/simple/dynamicemitters.qml delete mode 100644 examples/particles/simple/multiplepainters.qml delete mode 100644 examples/particles/simple/startstop.qml create mode 100644 examples/particles/system/content/dynamiccomparison.qml create mode 100644 examples/particles/system/content/dynamicemitters.qml create mode 100644 examples/particles/system/content/multiplepainters.qml create mode 100644 examples/particles/system/content/startstop.qml create mode 100644 examples/particles/system/content/timedgroupchanges.qml create mode 100644 examples/particles/system/main.cpp create mode 100644 examples/particles/system/system.pro create mode 100644 examples/particles/system/system.qml create mode 100644 examples/particles/system/system.qmlproject (limited to 'examples/particles') diff --git a/examples/particles/customparticle/blurparticles.qml b/examples/particles/customparticle/blurparticles.qml deleted file mode 100644 index 9b432e093d..0000000000 --- a/examples/particles/customparticle/blurparticles.qml +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - color: "white" - width: 240 - height: 360 - ParticleSystem { - id: sys - } - Emitter { - system:sys - height: parent.height - emitRate: 1 - lifeSpan: 12000 - velocity: PointDirection {x:20;} - size: 128 - } - ShaderEffectSource { - id: theSource - sourceItem: theItem - hideSource: true - } - Image { - id: theItem - source: "../images/starfish_1.png" - } - - CustomParticle { - system: sys - vertexShader:" - uniform lowp float qt_Opacity; - varying lowp float fFade; - varying lowp float fBlur; - - void main() { - defaultMain(); - highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; - highp float fadeIn = min(t * 10., 1.); - highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); - - fFade = fadeIn * fadeOut * qt_Opacity; - fBlur = max(0.2 * t, t * qt_ParticleR); - } - " - property variant source: theSource - property variant blurred: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(0.0, 1.0 / height) - property variant source: ShaderEffectSource { - smooth: true - sourceItem: ShaderEffect { - width: theItem.width - height: theItem.height - property variant delta: Qt.size(1.0 / width, 0.0) - property variant source: theSource - fragmentShader: " - uniform sampler2D source; - uniform lowp float qt_Opacity; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - fragmentShader: " - uniform sampler2D source; - uniform lowp float qt_Opacity; - uniform highp vec2 delta; - varying highp vec2 qt_TexCoord0; - void main() { - gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) - + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) - + 0.2466 * texture2D(source, qt_TexCoord0) - + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) - + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; - }" - } - } - fragmentShader: " - uniform sampler2D source; - uniform sampler2D blurred; - varying highp vec2 qt_TexCoord0; - varying highp float fBlur; - varying highp float fFade; - void main() { - gl_FragColor = mix(texture2D(source, qt_TexCoord0), texture2D(blurred, qt_TexCoord0), min(1.0,fBlur*3.0)) * fFade; - }" - - } -} - diff --git a/examples/particles/customparticle/content/blurparticles.qml b/examples/particles/customparticle/content/blurparticles.qml new file mode 100644 index 0000000000..c1ad03b04b --- /dev/null +++ b/examples/particles/customparticle/content/blurparticles.qml @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + color: "white" + width: 240 + height: 360 + ParticleSystem { + id: sys + } + Emitter { + system:sys + height: parent.height + emitRate: 1 + lifeSpan: 12000 + velocity: PointDirection {x:20;} + size: 128 + } + ShaderEffectSource { + id: theSource + sourceItem: theItem + hideSource: true + } + Image { + id: theItem + source: "../../images/starfish_1.png" + } + + CustomParticle { + system: sys + //! [vertex] + vertexShader:" + uniform lowp float qt_Opacity; + varying lowp float fFade; + varying lowp float fBlur; + + void main() { + defaultMain(); + highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; + highp float fadeIn = min(t * 10., 1.); + highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); + + fFade = fadeIn * fadeOut * qt_Opacity; + fBlur = max(0.2 * t, t * qt_ParticleR); + } + " + //! [vertex] + property variant source: theSource + property variant blurred: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(0.0, 1.0 / height) + property variant source: ShaderEffectSource { + smooth: true + sourceItem: ShaderEffect { + width: theItem.width + height: theItem.height + property variant delta: Qt.size(1.0 / width, 0.0) + property variant source: theSource + fragmentShader: " + uniform sampler2D source; + uniform lowp float qt_Opacity; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + fragmentShader: " + uniform sampler2D source; + uniform lowp float qt_Opacity; + uniform highp vec2 delta; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor =(0.0538 * texture2D(source, qt_TexCoord0 - 3.182 * delta) + + 0.3229 * texture2D(source, qt_TexCoord0 - 1.364 * delta) + + 0.2466 * texture2D(source, qt_TexCoord0) + + 0.3229 * texture2D(source, qt_TexCoord0 + 1.364 * delta) + + 0.0538 * texture2D(source, qt_TexCoord0 + 3.182 * delta)) * qt_Opacity; + }" + } + } + //! [fragment] + fragmentShader: " + uniform sampler2D source; + uniform sampler2D blurred; + varying highp vec2 qt_TexCoord0; + varying highp float fBlur; + varying highp float fFade; + 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/content/fragmentshader.qml b/examples/particles/customparticle/content/fragmentshader.qml new file mode 100644 index 0000000000..e2f4f92f08 --- /dev/null +++ b/examples/particles/customparticle/content/fragmentshader.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +ParticleSystem { + id: root + width: 320 + height: 480 + Rectangle { + z: -1 + anchors.fill: parent + color: "black" + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 14 + color: "white" + text: "It's all in the fragment shader." + } + } + + Emitter { + emitRate: 400 + lifeSpan: 8000 + size: 24 + sizeVariation: 16 + velocity: PointDirection {x: root.width/10; y: root.height/10;} + acceleration: PointDirection {x: -root.width/40; y: -root.height/40; xVariation: -root.width/20; yVariation: -root.width/20} + } + + CustomParticle { + vertexShader:" + uniform lowp float qt_Opacity; + varying lowp float fFade; + varying highp vec2 fPos; + + void main() { + qt_TexCoord0 = qt_ParticleTex; + highp float size = qt_ParticleData.z; + highp float endSize = qt_ParticleData.w; + + highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; + + highp float currentSize = mix(size, endSize, t * t); + + if (t < 0. || t > 1.) + currentSize = 0.; + + highp vec2 pos = qt_ParticlePos + - currentSize / 2. + currentSize * qt_ParticleTex // adjust size + + qt_ParticleVec.xy * t * qt_ParticleData.y // apply velocity vector.. + + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.); + + gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); + + highp float fadeIn = min(t * 20., 1.); + highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.)); + + fFade = fadeIn * fadeOut * qt_Opacity; + fPos = vec2(pos.x/320., pos.y/480.); + } + " + //! [0] + fragmentShader: " + varying highp vec2 fPos; + varying lowp float fFade; + varying highp vec2 qt_TexCoord0; + void main() {//*2 because this generates dark colors mostly + highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0); + highp float dist = length(circlePos); + 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/content/imagecolors.qml b/examples/particles/customparticle/content/imagecolors.qml new file mode 100644 index 0000000000..62345f75c1 --- /dev/null +++ b/examples/particles/customparticle/content/imagecolors.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + width: 400 + height: 400 + Rectangle { + id: root + color: "white" + width: 310 + height: 300 + anchors.centerIn: parent + ParticleSystem { id: sys } + CustomParticle { + system: sys + property real maxWidth: root.width + property real maxHeight: root.height + ShaderEffectSource { + id: pictureSource + sourceItem: picture + hideSource: true + } + Image { + id: picture + source: "../../images/starfish_3.png" + } + ShaderEffectSource { + id: particleSource + sourceItem: particle + hideSource: true + } + Image { + id: particle + source: "../../images/particle4.png" + } + //! [vertex] + vertexShader:" + uniform highp float maxWidth; + uniform highp float maxHeight; + varying highp vec2 fTex2; + varying lowp float fFade; + uniform lowp float qt_Opacity; + + void main() { + + 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; + varying highp vec2 qt_TexCoord0; + varying highp vec2 fTex2; + varying lowp float fFade; + void main() { + gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade; + }" + //! [fragment] + } + + Emitter { + id: emitter + system: sys + enabled: false + lifeSpan: 8000 + maximumEmitted: 4000 + anchors.fill: parent + size: 16 + acceleration: PointDirection { xVariation: 12; yVariation: 12 } + } + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(4000); + } + } +} 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/fragmentshader.qml b/examples/particles/customparticle/fragmentshader.qml deleted file mode 100644 index 367cc99b7b..0000000000 --- a/examples/particles/customparticle/fragmentshader.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -ParticleSystem { - id: root - width: 1024 - height: 768 - Rectangle { - z: -1 - anchors.fill: parent - color: "black" - Text { - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 36 - color: "white" - text: "It's all in the fragment shader." - } - } - - Emitter { - emitRate: 400 - lifeSpan: 8000 - 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} - } - - CustomParticle { - vertexShader:" - uniform lowp float qt_Opacity; - varying lowp float fFade; - varying highp vec2 fPos; - - void main() { - qt_TexCoord0 = qt_ParticleTex; - highp float size = qt_ParticleData.z; - highp float endSize = qt_ParticleData.w; - - highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; - - highp float currentSize = mix(size, endSize, t * t); - - if (t < 0. || t > 1.) - currentSize = 0.; - - highp vec2 pos = qt_ParticlePos - - currentSize / 2. + currentSize * qt_ParticleTex // adjust size - + qt_ParticleVec.xy * t * qt_ParticleData.y // apply velocity vector.. - + 0.5 * qt_ParticleVec.zw * pow(t * qt_ParticleData.y, 2.); - - gl_Position = qt_Matrix * vec4(pos.x, pos.y, 0, 1); - - highp float fadeIn = min(t * 20., 1.); - 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.); - } - " - fragmentShader: " - varying highp vec2 fPos; - varying lowp float fFade; - varying highp vec2 qt_TexCoord0; - void main() {//*2 because this generates dark colors mostly - highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0); - highp float dist = length(circlePos); - 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; - }" - - } -} diff --git a/examples/particles/customparticle/imagecolors.qml b/examples/particles/customparticle/imagecolors.qml deleted file mode 100644 index 94e5123a0c..0000000000 --- a/examples/particles/customparticle/imagecolors.qml +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - width: 400 - height: 400 - Rectangle { - id: root - color: "white" - width: 310 - height: 300 - anchors.centerIn: parent - ParticleSystem { id: sys } - CustomParticle { - system: sys - property real maxWidth: root.width - property real maxHeight: root.height - ShaderEffectSource { - id: pictureSource - sourceItem: picture - hideSource: true - } - Image { - id: picture - source: "../images/starfish_3.png" - } - ShaderEffectSource { - id: particleSource - sourceItem: particle - hideSource: true - } - Image { - id: particle - source: "../images/particle4.png" - } - vertexShader:" - uniform highp float maxWidth; - uniform highp float maxHeight; - varying highp vec2 fTex2; - varying lowp float fFade; - uniform lowp float qt_Opacity; - - void main() { - fTex2 = vec2(qt_ParticlePos.x / maxWidth, qt_ParticlePos.y / maxHeight); - highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y; - fFade = min(t*4., (1.-t*t)*.75) * qt_Opacity; - defaultMain(); - } - " - property variant particleTexture: particleSource - property variant pictureTexture: pictureSource - fragmentShader: " - uniform sampler2D particleTexture; - uniform sampler2D pictureTexture; - varying highp vec2 qt_TexCoord0; - varying highp vec2 fTex2; - varying lowp float fFade; - void main() { - gl_FragColor = texture2D(pictureTexture, fTex2) * texture2D(particleTexture, qt_TexCoord0).w * fFade; - }" - } - - Emitter { - id: emitter - system: sys - enabled: false - lifeSpan: 8000 - maximumEmitted: 4000 - anchors.fill: parent - size: 16 - acceleration: PointDirection { xVariation: 12; yVariation: 12 } - } - MouseArea { - anchors.fill: parent - onClicked: emitter.burst(4000); - } - } -} 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/burstandpulse.qml deleted file mode 100644 index c6d39b527d..0000000000 --- a/examples/particles/emitters/burstandpulse.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - 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); - } - } - - ParticleSystem { - id: particles - } - - ImageParticle { - anchors.fill: parent - system: particles - 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 - } -} diff --git a/examples/particles/emitters/content/burstandpulse.qml b/examples/particles/emitters/content/burstandpulse.qml new file mode 100644 index 0000000000..377ce9dd0e --- /dev/null +++ b/examples/particles/emitters/content/burstandpulse.qml @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + width: 320 + height: 480 + color: "black" + 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 + anchors.fill: parent + ImageParticle { + source: "../../images/star.png" + alpha: 0 + colorVariation: 0.6 + } + + 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/content/customemitter.qml b/examples/particles/emitters/content/customemitter.qml new file mode 100644 index 0000000000..baa513ba11 --- /dev/null +++ b/examples/particles/emitters/content/customemitter.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 QtQuick.Particles 2.0 + +ParticleSystem { + id: sys + width: 360 + height: 600 + running: true + Rectangle { + z: -1 + anchors.fill: parent + color: "black" + } + + property real petalLength: 180 + property real petalRotation: 0 + NumberAnimation on petalRotation { + from: 0; + to: 360; + loops: -1; + running: true + duration: 24000 + } + + function convert(a) {return a*(Math.PI/180);} + Emitter { + lifeSpan: 4000 + emitRate: 120 + size: 12 + anchors.centerIn: parent + //! [0] + onEmitParticles: { + for (var i=0; i 400 ? 32 : 16 - } -} diff --git a/examples/particles/imageparticle/colored.qml b/examples/particles/imageparticle/colored.qml deleted file mode 100644 index 8ae9a8e0bc..0000000000 --- a/examples/particles/imageparticle/colored.qml +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - ParticleSystem { - anchors.fill: parent - ImageParticle { - groups: ["stars"] - anchors.fill: parent - source: "../images/star.png" - } - Emitter { - group: "stars" - emitRate: 800 - lifeSpan: 2400 - size: 24 - sizeVariation: 8 - anchors.fill: parent - } - - ImageParticle { - anchors.fill: parent - source: "../images/star.png" - alpha: 0 - alphaVariation: 0.2 - colorVariation: 1.0 - } - - Emitter { - anchors.centerIn: parent - emitRate: 400 - lifeSpan: 2400 - size: 48 - sizeVariation: 8 - velocity: AngleDirection {angleVariation: 180; magnitude: 60} - } - - Turbulence { - anchors.fill: parent - strength: 2 - } - } -} diff --git a/examples/particles/imageparticle/colortable.qml b/examples/particles/imageparticle/colortable.qml deleted file mode 100644 index e7c9b5c176..0000000000 --- a/examples/particles/imageparticle/colortable.qml +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** 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.Particles 2.0 -import QtQuick 2.0 - -Rectangle { - id: root - width: 360 - height: 540 - color: "black" - - ParticleSystem { id: particles } - - ImageParticle { - system: particles - colorVariation: 0.5 - alpha: 0 - - source: "../images/particle.png" - colorTable: "../images/colortable.png" - sizeTable: "../images/colortable.png" - } - - Emitter { - system: particles - emitRate: 500 - lifeSpan: 2000 - - y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 - x: root.width / 2 + Math.cos(t) * root.width * 0.3 - property real t; - - NumberAnimation on t { - from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite - } - - velocityFromMovement: 20 - - velocity: PointDirection { xVariation: 5; yVariation: 5;} - acceleration: PointDirection { xVariation: 5; yVariation: 5;} - - size: 16 - //endSize: 8 - //sizeVariation: 8 - } -} diff --git a/examples/particles/imageparticle/content/allatonce.qml b/examples/particles/imageparticle/content/allatonce.qml new file mode 100644 index 0000000000..a417e62e5b --- /dev/null +++ b/examples/particles/imageparticle/content/allatonce.qml @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + color: "white" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + + ImageParticle { + // ![0] + sprites: [ + Sprite { + name: "bear" + source: "../../images/bear_tiles.png" + frameCount: 13 + frameDuration: 120 + } + ] + colorVariation: 0.5 + rotationVelocityVariation: 360 + colorTable: "../../images/colortable.png" + // ![0] + system: sys + } + + Friction { + factor: 0.1 + system: sys + } + + Emitter { + system: sys + anchors.centerIn: parent + id: particles + emitRate: 200 + lifeSpan: 6000 + velocity: AngleDirection {angleVariation: 360; magnitude: 80; magnitudeVariation: 40} + size: 60 + endSize: 120 + } + + Text { + x: 16 + y: 16 + text: "QML..." + style: Text.Outline; styleColor: "#AAAAAA" + font.pixelSize: 32 + } + Text { + anchors.bottom: parent.bottom + anchors.right: parent.right + anchors.margins: 16 + text: "... can you be trusted with the power?" + style: Text.Outline; styleColor: "#AAAAAA" + font.pixelSize: width > 400 ? 32 : 16 + } +} diff --git a/examples/particles/imageparticle/content/colored.qml b/examples/particles/imageparticle/content/colored.qml new file mode 100644 index 0000000000..2a9ccd779a --- /dev/null +++ b/examples/particles/imageparticle/content/colored.qml @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 540 + color: "black" + ParticleSystem { + anchors.fill: parent + ImageParticle { + groups: ["stars"] + anchors.fill: parent + source: "../../images/star.png" + } + Emitter { + group: "stars" + emitRate: 800 + lifeSpan: 2400 + size: 24 + sizeVariation: 8 + anchors.fill: parent + } + + // ![0] + ImageParticle { + anchors.fill: parent + source: "../../images/star.png" + alpha: 0 + alphaVariation: 0.2 + colorVariation: 1.0 + } + // ![0] + + Emitter { + anchors.centerIn: parent + emitRate: 400 + lifeSpan: 2400 + size: 48 + sizeVariation: 8 + velocity: AngleDirection {angleVariation: 180; magnitude: 60} + } + + Turbulence { + anchors.fill: parent + strength: 2 + } + } +} diff --git a/examples/particles/imageparticle/content/colortable.qml b/examples/particles/imageparticle/content/colortable.qml new file mode 100644 index 0000000000..5b8fbf2316 --- /dev/null +++ b/examples/particles/imageparticle/content/colortable.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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.Particles 2.0 +import QtQuick 2.0 + +Rectangle { + id: root + width: 360 + height: 540 + color: "black" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + colorVariation: 0.5 + alpha: 0 + + //! [0] + source: "../../images/particle.png" + colorTable: "../../images/colortable.png" + sizeTable: "../../images/colortable.png" + //! [0] + } + + Emitter { + system: particles + emitRate: 500 + lifeSpan: 2000 + + y: root.height / 2 + Math.sin(t * 2) * root.height * 0.3 + x: root.width / 2 + Math.cos(t) * root.width * 0.3 + property real t; + + NumberAnimation on t { + from: 0; to: Math.PI * 2; duration: 10000; loops: Animation.Infinite + } + + velocityFromMovement: 20 + + velocity: PointDirection { xVariation: 5; yVariation: 5;} + acceleration: PointDirection { xVariation: 5; yVariation: 5;} + + size: 16 + //endSize: 8 + //sizeVariation: 8 + } +} diff --git a/examples/particles/imageparticle/content/deformation.qml b/examples/particles/imageparticle/content/deformation.qml new file mode 100644 index 0000000000..ea3f741159 --- /dev/null +++ b/examples/particles/imageparticle/content/deformation.qml @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 400 + height: 400 + ParticleSystem {id:sys} + + //! [spin] + ImageParticle { + system: sys + groups: ["goingLeft", "goingRight"] + source: "../../images/starfish_4.png" + rotation: 90 + rotationVelocity: 90 + autoRotation: true + } + //! [spin] + //! [deform] + ImageParticle { + system: sys + groups: ["goingDown"] + source: "../../images/starfish_0.png" + rotation: 180 + yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } + } + //! [deform] + + Timer { + running: true + repeat: false + interval: 100 + onTriggered: emitA.enabled = true; + } + Timer { + running: true + repeat: false + interval: 4200 + onTriggered: emitB.enabled = true; + } + Timer { + running: true + repeat: false + interval: 8400 + onTriggered: emitC.enabled = true; + } + + Emitter { + id: emitA + x: 0 + y: 120 + system: sys + enabled: false + group: "goingRight" + velocity: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitB + x: 400 + y: 240 + system: sys + enabled: false + group: "goingLeft" + velocity: PointDirection { x: -100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitC + x: 0 + y: 360 + system: sys + enabled: false + group: "goingDown" + velocity: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } +} diff --git a/examples/particles/imageparticle/content/rotation.qml b/examples/particles/imageparticle/content/rotation.qml new file mode 100644 index 0000000000..4f95fa23b8 --- /dev/null +++ b/examples/particles/imageparticle/content/rotation.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + color: "goldenrod" + width: 2000 + height: 2000 + ParticleSystem {id: sys} + ImageParticle { + id: up + system: sys + source: "../../images/starfish_2.png" + autoRotation: true //leaving these two settings at default allows you to test going up performance levels + rotation: -90 + } + + Emitter { + anchors.centerIn: parent + system: sys + emitRate: 10 + size: 200 + lifeSpan: 10000 + velocity: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} + } + + MouseArea { + anchors.fill: parent + onClicked: { + up.autoRotation = !up.autoRotation + up.rotation = up.autoRotation ? -90 : 0 + } + } +} diff --git a/examples/particles/imageparticle/content/sharing.qml b/examples/particles/imageparticle/content/sharing.qml new file mode 100644 index 0000000000..3fe50c8a2c --- /dev/null +++ b/examples/particles/imageparticle/content/sharing.qml @@ -0,0 +1,203 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringAnimation to provide custom movement when the +// highlight bar is moved between items. + +import QtQuick 2.0 +import QtQuick.Particles 2.0 + +Rectangle { + property real delegateHeight: 65 + width: 200; height: 300 + gradient: Gradient { + GradientStop { position: 0.0; color: "#EEEEFF" } + GradientStop { position: 1.0; color: "lightblue" } + } + + // Define a delegate component. A component will be + // instantiated for each visible item in the list. + Component { + id: petDelegate + Item { + id: wrapper + width: 200; height: delegateHeight + z: 10 + Column { + Text {color: "white"; text: name; font.pixelSize: 18 } + Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 } + Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 } + } + // indent the item if it is the current item + states: State { + name: "Current" + when: wrapper.ListView.isCurrentItem + PropertyChanges { target: wrapper; x: 20 } + } + transitions: Transition { + NumberAnimation { properties: "x"; duration: 200 } + } + } + } + + // Define a highlight with customised movement between items. + Component { + id: highlightBar + Rectangle { + z: 0 + width: 200; height: delegateHeight + gradient: Gradient { + GradientStop { position: 0.0; color: "#99FF99" } + GradientStop { position: 1.0; color: "#88FF88" } + } + y: listView.currentItem.y; + Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } + //! [1] + ImageParticle { + anchors.fill: parent + system: particles + source: "../../images/flower.png" + color: "red" + clip: true + alpha: 1.0 + } + //! [1] + } + } + + ListView { + id: listView + width: 200; height: parent.height + + model: petsModel + delegate: petDelegate + focus: true + + // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem + // to false so the highlight delegate can control how the highlight is moved. + highlight: highlightBar + highlightFollowsCurrentItem: false + + ParticleSystem { id: particles } + Emitter { + system: particles + anchors.fill: parent + emitRate: 1 + lifeSpan: 10000 + size: 24 + sizeVariation: 8 + velocity: AngleDirection { angleVariation: 360; magnitude: 3 } + maximumEmitted: 10 + startTime: 5000 + } + + //! [0] + ImageParticle { + anchors.fill: parent + system: particles + source: "../../images/flower.png" + alpha: 0.1 + color: "white" + rotationVariation: 180 + z: -1 + } + //! [0] + } + + ListModel { + id: petsModel + ListElement { + name: "Polly" + type: "Parrot" + age: 12 + size: "Small" + } + ListElement { + name: "Penny" + type: "Turtle" + age: 4 + size: "Small" + } + ListElement { + name: "Warren" + type: "Rabbit" + age: 2 + size: "Small" + } + ListElement { + name: "Spot" + type: "Dog" + age: 9 + size: "Medium" + } + ListElement { + name: "Schrödinger" + type: "Cat" + age: 2 + size: "Medium" + } + ListElement { + name: "Joey" + type: "Kangaroo" + age: 1 + size: "Medium" + } + ListElement { + name: "Kimba" + type: "Bunny" + age: 65 + size: "Large" + } + ListElement { + name: "Rover" + type: "Dog" + age: 5 + size: "Large" + } + ListElement { + name: "Tiny" + type: "Elephant" + age: 15 + size: "Large" + } + } + +} diff --git a/examples/particles/imageparticle/content/sprites.qml b/examples/particles/imageparticle/content/sprites.qml new file mode 100644 index 0000000000..2f5baaf002 --- /dev/null +++ b/examples/particles/imageparticle/content/sprites.qml @@ -0,0 +1,116 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + color: "lightsteelblue" + width: 800 + height: 800 + id: root + + SpriteSequence { + sprites: Sprite { + name: "bear" + source: "../../images/bear_tiles.png" + frameCount: 13 + frameDuration: 120 + } + width: 250 + height: 250 + x: 20 + anchors.bottom: parent.bottom + anchors.bottomMargin: 20 + z:4 + } + + ParticleSystem { id: sys } + + ImageParticle { + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite { + name: "happy" + source: "../../images/starfish_1.png" + frameCount: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "angry" + source: "../../images/starfish_0.png" + frameCount: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "silly" + source: "../../images/starfish_2.png" + frameCount: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "noticedbear": 0} + }, Sprite { + name: "noticedbear" + source: "../../images/starfish_3.png" + frameCount: 1 + frameDuration: 2600 + }] + } + + Emitter { + system: sys + emitRate: 2 + lifeSpan: 10000 + velocity: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} + acceleration: PointDirection { y: 10 } + size: 160 + sizeVariation: 40 + width: parent.width + height: 100 + } + + SpriteGoal { + system: sys + width: root.width; + height: root.height/2; + y: root.height/2; + goalState:"noticedbear" + } +} diff --git a/examples/particles/imageparticle/deformation.qml b/examples/particles/imageparticle/deformation.qml deleted file mode 100644 index 0fca37e3e1..0000000000 --- a/examples/particles/imageparticle/deformation.qml +++ /dev/null @@ -1,121 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 400 - height: 400 - ParticleSystem {id:sys} - - ImageParticle { - system: sys - groups: ["goingLeft", "goingRight"] - source: "../images/starfish_4.png" - rotation: 90 - rotationVelocity: 90 - autoRotation: true - } - ImageParticle { - system: sys - groups: ["goingDown"] - source: "../images/starfish_0.png" - rotation: 180 - yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; } - } - - Timer { - running: true - repeat: false - interval: 100 - onTriggered: emitA.enabled = true; - } - Timer { - running: true - repeat: false - interval: 4200 - onTriggered: emitB.enabled = true; - } - Timer { - running: true - repeat: false - interval: 8400 - onTriggered: emitC.enabled = true; - } - - Emitter { - id: emitA - x: 0 - y: 120 - system: sys - enabled: false - group: "goingRight" - velocity: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitB - x: 400 - y: 240 - system: sys - enabled: false - group: "goingLeft" - velocity: PointDirection { x: -100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } - Emitter { - id: emitC - x: 0 - y: 360 - system: sys - enabled: false - group: "goingDown" - velocity: PointDirection { x: 100 } - lifeSpan: 4000 - emitRate: 1 - size: 128 - } -} 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/imageparticle/rotation.qml b/examples/particles/imageparticle/rotation.qml deleted file mode 100644 index 34e063b1f5..0000000000 --- a/examples/particles/imageparticle/rotation.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - color: "goldenrod" - width: 2000 - height: 2000 - ParticleSystem {id: sys} - ImageParticle { - id: up - system: sys - source: "../images/starfish_2.png" - } - - Emitter { - anchors.centerIn: parent - system: sys - emitRate: 10 - size: 200 - lifeSpan: 10000 - velocity: AngleDirection {angleVariation: 360; magnitudeVariation: 100;} - } - - MouseArea { - anchors.fill: parent - onClicked: { - up.autoRotation = !up.autoRotation - up.rotation = up.autoRotation ? -90 : 0 - } - } -} diff --git a/examples/particles/imageparticle/sharing.qml b/examples/particles/imageparticle/sharing.qml deleted file mode 100644 index d1a516fc49..0000000000 --- a/examples/particles/imageparticle/sharing.qml +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -// This example shows how to create your own highlight delegate for a ListView -// that uses a SpringAnimation to provide custom movement when the -// highlight bar is moved between items. - -import QtQuick 2.0 -import QtQuick.Particles 2.0 - -Rectangle { - property real delegateHeight: 65 - width: 200; height: 300 - gradient: Gradient { - GradientStop { position: 0.0; color: "#EEEEFF" } - GradientStop { position: 1.0; color: "lightblue" } - } - - // Define a delegate component. A component will be - // instantiated for each visible item in the list. - Component { - id: petDelegate - Item { - id: wrapper - width: 200; height: delegateHeight - z: 10 - Column { - Text {color: "white"; text: name; font.pixelSize: 18 } - Text {color: "white"; text: 'Type: ' + type; font.pixelSize: 14 } - Text {color: "white"; text: 'Age: ' + age; font.pixelSize: 14 } - } - // indent the item if it is the current item - states: State { - name: "Current" - when: wrapper.ListView.isCurrentItem - PropertyChanges { target: wrapper; x: 20 } - } - transitions: Transition { - NumberAnimation { properties: "x"; duration: 200 } - } - } - } - - // Define a highlight with customised movement between items. - Component { - id: highlightBar - Rectangle { - z: 0 - width: 200; height: delegateHeight - gradient: Gradient { - GradientStop { position: 0.0; color: "#99FF99" } - GradientStop { position: 1.0; color: "#88FF88" } - } - y: listView.currentItem.y; - Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/flower.png" - color: "red" - clip: true - alpha: 1.0 - } - } - } - - ListView { - id: listView - width: 200; height: parent.height - - model: petsModel - delegate: petDelegate - focus: true - - // Set the highlight delegate. Note we must also set highlightFollowsCurrentItem - // to false so the highlight delegate can control how the highlight is moved. - highlight: highlightBar - highlightFollowsCurrentItem: false - - ParticleSystem { id: particles } - Emitter { - system: particles - anchors.fill: parent - emitRate: 1 - lifeSpan: 10000 - size: 24 - sizeVariation: 8 - velocity: AngleDirection { angleVariation: 360; magnitude: 3 } - maximumEmitted: 10 - startTime: 5000 - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/flower.png" - alpha: 0.1 - color: "white" - rotationVariation: 180 - z: -1 - } - } - - ListModel { - id: petsModel - ListElement { - name: "Polly" - type: "Parrot" - age: 12 - size: "Small" - } - ListElement { - name: "Penny" - type: "Turtle" - age: 4 - size: "Small" - } - ListElement { - name: "Warren" - type: "Rabbit" - age: 2 - size: "Small" - } - ListElement { - name: "Spot" - type: "Dog" - age: 9 - size: "Medium" - } - ListElement { - name: "Schrödinger" - type: "Cat" - age: 2 - size: "Medium" - } - ListElement { - name: "Joey" - type: "Kangaroo" - age: 1 - size: "Medium" - } - ListElement { - name: "Kimba" - type: "Bunny" - age: 65 - size: "Large" - } - ListElement { - name: "Rover" - type: "Dog" - age: 5 - size: "Large" - } - ListElement { - name: "Tiny" - type: "Elephant" - age: 15 - size: "Large" - } - } - -} diff --git a/examples/particles/imageparticle/sprites.qml b/examples/particles/imageparticle/sprites.qml deleted file mode 100644 index 1e5aaa0f75..0000000000 --- a/examples/particles/imageparticle/sprites.qml +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - color: "lightsteelblue" - width: 800 - height: 800 - id: root - - SpriteSequence { - sprites: Sprite { - name: "bear" - source: "../images/bear_tiles.png" - frameCount: 13 - frameDuration: 120 - } - width: 250 - height: 250 - x: 20 - anchors.bottom: parent.bottom - anchors.bottomMargin: 20 - z:4 - } - - ParticleSystem { id: sys } - - ImageParticle { - anchors.fill: parent - id: particles - system: sys - sprites: [Sprite { - name: "happy" - source: "../images/starfish_1.png" - frameCount: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "angry" - source: "../images/starfish_0.png" - frameCount: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "angry": 1} - }, Sprite { - name: "silly" - source: "../images/starfish_2.png" - frameCount: 1 - frameDuration: 260 - to: {"happy": 1, "silly": 1, "noticedbear": 0} - }, Sprite { - name: "noticedbear" - source: "../images/starfish_3.png" - frameCount: 1 - frameDuration: 2600 - }] - } - - Emitter { - system: sys - emitRate: 2 - lifeSpan: 10000 - velocity: AngleDirection {angle: 90; magnitude: 60; angleVariation: 5} - acceleration: PointDirection { y: 10 } - size: 160 - sizeVariation: 40 - width: parent.width - height: 100 - } - - SpriteGoal { - system: sys - width: root.width; - height: root.height/2; - y: root.height/2; - goalState:"noticedbear" - } -} 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/simple/dynamiccomparison.qml deleted file mode 100644 index d244e0e770..0000000000 --- a/examples/particles/simple/dynamiccomparison.qml +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - - ImageParticle { - system: sys - source: "../images/particle.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - entryEffect: ImageParticle.None - } - - Emitter { - id: emitter - system: sys - width: parent.width/2 - velocity: PointDirection {y: 72; yVariation: 24} - lifeSpan: 10000 - emitRate: 1000 - enabled: false - size: 32 - } - - 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.y = 0; - number--; - } - } - - Component { - id: fakeParticle - Image { - id: container - property int lifeSpan: 10000 - width: 32 - height: 32 - source: "../images/particle.png" - y: 0 - PropertyAnimation on y {from: -16; to: 480-16; duration: container.lifeSpan; running: true} - SequentialAnimation on opacity { - running: true - NumberAnimation { from:0; to: 1; duration: 500} - PauseAnimation { duration: container.lifeSpan - 1000} - NumberAnimation { from:1; to: 0; duration: 500} - ScriptAction { script: container.destroy(); } - } - } - } - } - - Text { - anchors.left: parent.left - anchors.bottom: parent.bottom - text: "1000 particles" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: emitter.burst(1000); - } - } - Text { - anchors.right: parent.right - anchors.bottom: parent.bottom - text: "1000 items" - color: "white" - MouseArea { - anchors.fill: parent - onClicked: fakeEmitter.burst(1000); - } - } -} diff --git a/examples/particles/simple/dynamicemitters.qml b/examples/particles/simple/dynamicemitters.qml deleted file mode 100644 index 8f007f3fdc..0000000000 --- a/examples/particles/simple/dynamicemitters.qml +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - color: "black" - width: 640 - height: 480 - ParticleSystem { - id: sys - } - ImageParticle { - system: sys - source: "../images/particle.png" - color: "white" - colorVariation: 1.0 - alpha: 0.1 - } - - Component { - id: emitterComp - Emitter { - id: container - Emitter { - id: emitMore - system: sys - emitRate: 128 - lifeSpan: 600 - size: 16 - endSize: 8 - velocity: AngleDirection {angleVariation:360; magnitude: 60} - } - - property int life: 2600 - property real targetX: 0 - property real targetY: 0 - function go() { - xAnim.start(); - yAnim.start(); - container.enabled = true - } - system: sys - emitRate: 32 - lifeSpan: 600 - size: 24 - endSize: 8 - NumberAnimation on x { - id: xAnim; - to: targetX - duration: life - running: false - } - NumberAnimation on y { - id: yAnim; - to: targetY - duration: life - running: false - } - Timer { - interval: life - running: true - onTriggered: container.destroy(); - } - } - } - - 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(); - } - } - } -} diff --git a/examples/particles/simple/multiplepainters.qml b/examples/particles/simple/multiplepainters.qml deleted file mode 100644 index 62a254812d..0000000000 --- a/examples/particles/simple/multiplepainters.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - id: root - width: 360 - height: 600 - color: "darkblue" - property bool cloneMode: false - ParticleSystem { - id: sys - } - MouseArea { - anchors.fill: parent - onClicked: cloneMode = !cloneMode; - } - Emitter { - system: sys - y:root.height + 20 - width: root.width - emitRate: 200 - lifeSpan: 4000 - startTime: 4000 - velocity: PointDirection { y: -120; } - } - - ImageParticle { - system: sys - visible: !cloneMode - source: "../images/particle2.png" - } - - ImageParticle { - system: sys - visible: cloneMode - z: 0 - source: "../images/particle3.png" - } - - ImageParticle { - system: sys - clip: true - visible: cloneMode - y: 120 - height: 240 - width: root.width - z: 1 - source: "../images/particle.png" - } -} diff --git a/examples/particles/simple/startstop.qml b/examples/particles/simple/startstop.qml deleted file mode 100644 index 62105b28a0..0000000000 --- a/examples/particles/simple/startstop.qml +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** 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 QtQuick.Particles 2.0 - -Rectangle { - width: 360 - height: 540 - color: "black" - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: { - if (mouse.button == Qt.LeftButton) - particles.running = !particles.running - else - particles.paused = !particles.paused; - } - } - - ParticleSystem { - id: particles - running: false - } - - ImageParticle { - anchors.fill: parent - system: particles - source: "../images/star.png" - sizeTable: "../images/sparkleSize.png" - alpha: 0 - colorVariation: 0.6 - } - - Emitter { - anchors.fill: parent - system: particles - emitRate: 2000 - lifeSpan: 2000 - size: 30 - sizeVariation: 10 - } -} diff --git a/examples/particles/system/content/dynamiccomparison.qml b/examples/particles/system/content/dynamiccomparison.qml new file mode 100644 index 0000000000..5084aea25c --- /dev/null +++ b/examples/particles/system/content/dynamiccomparison.qml @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + + ImageParticle { + system: sys + source: "../../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + entryEffect: ImageParticle.None + } + + Emitter { + id: emitter + system: sys + width: parent.width/2 + velocity: PointDirection {y: 72; yVariation: 24} + lifeSpan: 10000 + emitRate: 1000 + enabled: false + 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() * (root.width/2) + (root.width/2); + item.y = 0; + number--; + } + } + + Component { + id: fakeParticle + Image { + id: container + property int lifeSpan: 10000 + width: 32 + height: 32 + source: "../../images/particle.png" + y: 0 + 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} + PauseAnimation { duration: container.lifeSpan - 1000} + NumberAnimation { from:1; to: 0; duration: 500} + ScriptAction { script: container.destroy(); } + } + } + } + } + //! [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 + text: "1000 particles" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: emitter.burst(1000); + } + } + Text { + anchors.right: parent.right + anchors.bottom: parent.bottom + text: "1000 items" + color: "white" + MouseArea { + anchors.fill: parent + onClicked: fakeEmitter.burst(1000); + } + } +} diff --git a/examples/particles/system/content/dynamicemitters.qml b/examples/particles/system/content/dynamicemitters.qml new file mode 100644 index 0000000000..5fa4960109 --- /dev/null +++ b/examples/particles/system/content/dynamicemitters.qml @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + id: root + color: "black" + width: 640 + height: 480 + ParticleSystem { + id: sys + } + ImageParticle { + system: sys + source: "../../images/particle.png" + color: "white" + colorVariation: 1.0 + alpha: 0.1 + } + + Component { + id: emitterComp + Emitter { + id: container + Emitter { + id: emitMore + system: sys + emitRate: 128 + lifeSpan: 600 + size: 16 + endSize: 8 + velocity: AngleDirection {angleVariation:360; magnitude: 60} + } + + property int life: 2600 + property real targetX: 0 + property real targetY: 0 + function go() { + xAnim.start(); + yAnim.start(); + container.enabled = true + } + system: sys + emitRate: 32 + lifeSpan: 600 + size: 24 + endSize: 8 + NumberAnimation on x { + id: xAnim; + to: targetX + duration: life + running: false + } + NumberAnimation on y { + id: yAnim; + to: targetY + duration: life + running: false + } + Timer { + interval: life + running: true + onTriggered: container.destroy(); + } + } + } + + 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: customEmit(mouse.x, mouse.y); + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: "Click Somewhere" + color: "white" + font.pixelSize: 24 + } +} diff --git a/examples/particles/system/content/multiplepainters.qml b/examples/particles/system/content/multiplepainters.qml new file mode 100644 index 0000000000..e2f9f17a82 --- /dev/null +++ b/examples/particles/system/content/multiplepainters.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 QtQuick.Particles 2.0 + +Rectangle { + id: root + width: 360 + height: 600 + color: "darkblue" + property bool cloneMode: false + ParticleSystem { + id: sys + } + MouseArea { + 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 + width: root.width + emitRate: 200 + lifeSpan: 4000 + startTime: 4000 + velocity: PointDirection { y: -120; } + } + + ImageParticle { + system: sys + visible: !cloneMode + source: "../../images/particle2.png" + } + + ImageParticle { + system: sys + visible: cloneMode + z: 0 + source: "../../images/particle3.png" + } + + ImageParticle { + system: sys + clip: true + visible: cloneMode + y: 120 + height: 240 + width: root.width + z: 1 + source: "../../images/particle.png" + } +} diff --git a/examples/particles/system/content/startstop.qml b/examples/particles/system/content/startstop.qml new file mode 100644 index 0000000000..501d206db7 --- /dev/null +++ b/examples/particles/system/content/startstop.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +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 + onClicked: { + if (mouse.button == Qt.LeftButton) + particles.running = !particles.running + else + particles.paused = !particles.paused; + } + } + + ParticleSystem { + id: particles + running: false + } + + ImageParticle { + anchors.fill: parent + system: particles + source: "../../images/star.png" + sizeTable: "../../images/sparkleSize.png" + alpha: 0 + colorVariation: 0.6 + } + + Emitter { + anchors.fill: parent + system: particles + emitRate: 2000 + lifeSpan: 2000 + size: 30 + sizeVariation: 10 + } +} diff --git a/examples/particles/system/content/timedgroupchanges.qml b/examples/particles/system/content/timedgroupchanges.qml new file mode 100644 index 0000000000..8d6961b965 --- /dev/null +++ b/examples/particles/system/content/timedgroupchanges.qml @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** 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 QtQuick.Particles 2.0 + +Rectangle { + width: 360 + height: 600 + color: "black" + ParticleSystem { + anchors.fill: parent + id: syssy + //! [0] + ParticleGroup { + name: "fire" + duration: 2000 + durationVariation: 2000 + to: {"splode":1} + } + //! [0] + //! [1] + ParticleGroup { + name: "splode" + duration: 400 + to: {"dead":1} + TrailEmitter { + group: "works" + emitRatePerParticle: 100 + lifeSpan: 1000 + maximumEmitted: 1200 + size: 8 + velocity: AngleDirection {angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;} + acceleration: PointDirection {y:100; yVariation: 20} + } + } + //! [1] + //! [2] + ParticleGroup { + name: "dead" + duration: 1000 + Affector { + once: true + onAffected: worksEmitter.burst(400,x,y) + } + } + //! [2] + + Timer { + interval: 6000 + running: true + triggeredOnStart: true + repeat: true + onTriggered:startingEmitter.pulse(100); + } + Emitter { + id: startingEmitter + group: "fire" + width: parent.width + y: parent.height + enabled: false + emitRate: 80 + lifeSpan: 6000 + velocity: PointDirection {y:-100;} + size: 32 + } + + Emitter { + id: worksEmitter + group: "works" + enabled: false + emitRate: 100 + lifeSpan: 1600 + maximumEmitted: 6400 + size: 8 + velocity: CumulativeDirection { + PointDirection {y:-100} + AngleDirection {angleVariation: 360; magnitudeVariation: 80;} + } + acceleration: PointDirection {y:100; yVariation: 20} + } + + ImageParticle { + groups: ["works", "fire", "splode"] + 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: "." + } +} -- cgit v1.2.3