diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2012-02-20 10:34:44 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-24 10:24:58 +0100 |
commit | 9d2b618fa022daeabd45e57aa1596197db883037 (patch) | |
tree | 90536e9fc088d734439921dde304b49fe7f38df0 /examples/particles | |
parent | 91d543f00904a6caa2fab850ff3eca12de2d65ac (diff) |
Start of examples refactor
This is the general reorg of the examples directory structure, plus additional
guidelines.
calculator, animations and accessibility have been updated to the new standards
and tested, as an example.
Task-number: QTBUG-24133
Change-Id: I76c3b86751d3195ba2a5474ff23afb875765e9a4
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'examples/particles')
116 files changed, 5181 insertions, 0 deletions
diff --git a/examples/particles/affectors/age.qml b/examples/particles/affectors/age.qml new file mode 100644 index 0000000000..1e7774b63b --- /dev/null +++ b/examples/particles/affectors/age.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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: "white" + + ParticleSystem { id: particles } + + ImageParticle { + system: particles + sprites: Sprite { + name: "snow" + source: "../images/snowflake.png" + frames: 51 + frameDuration: 40 + frameDurationVariation: 8 + } + } + + Emitter { + system: particles + emitRate: 20 + lifeSpan: 8000 + speed: PointDirection { y:80; yVariation: 40; } + acceleration: PointDirection { y: 4 } + size: 36 + endSize: 12 + sizeVariation: 8 + width: parent.width + height: 100 + } + + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + } + + Rectangle { + color: "#803333AA" + border.color: "black" + x: ma.mouseX - 36 + y: ma.mouseY - 36 + width: 72 + height: 72 + Age { + anchors.fill: parent + system: particles + once: true + lifeLeft: 1200 + advancePosition: false + } + } +} diff --git a/examples/particles/affectors/attractor.qml b/examples/particles/affectors/attractor.qml new file mode 100644 index 0000000000..460a497a92 --- /dev/null +++ b/examples/particles/affectors/attractor.qml @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** 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: 540 + color: "black" + property bool spacePressed: false + focus: true + Image { + source: "../images/finalfrontier.png" + anchors.centerIn:parent + } + Keys.onPressed: { + if (event.key == Qt.Key_Space) { + spacePressed = true; + event.accepted = true; + } + } + Keys.onReleased: { + if (event.key == Qt.Key_Space) { + spacePressed = false; + event.accepted = true; + } + } + + Emitter { + group: "stars" + system: particles + emitRate: 40 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + Emitter { + group: "roids" + system: particles + emitRate: 10 + lifeSpan: 4000 + enabled: true + size: 30 + sizeVariation: 10 + speed: PointDirection { x: 220; xVariation: 40 } + height: parent.height + } + ParticleSystem { + id: particles + anchors.fill: parent + } + ImageParticle { + id: stars + groups: ["stars"] + system: particles + source: "../images/star.png" + color: "white" + colorVariation: 0.1 + alpha: 0 + } + ImageParticle { + id: roids + groups: ["roids"] + system: particles + sprites: Sprite { + id: spinState + name: "spinning" + source: "../images/meteor.png" + frames: 35 + frameDuration: 60 + } + } + ImageParticle { + id: shot + groups: ["shot"] + system: particles + source: "../images/star.png" + + color: "#0FF06600" + colorVariation: 0.3 + } + ImageParticle { + id: engine + groups: ["engine"] + system: particles + source: "../images/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + Attractor { + id: gs; pointX: root.width/2; pointY: root.height/2; strength: 4000000; + system: particles + affectedParameter: Attractor.Acceleration + proportionalToDistance: Attractor.InverseQuadratic + } + Age { + system: particles + x: gs.pointX - 8; + y: gs.pointY - 8; + width: 16 + height: 16 + } + Rectangle { + color: "black" + width: 8 + height: 8 + radius: 4 + x: gs.pointX - 4 + y: gs.pointY - 4 + } + + Image { + source:"../images/rocket2.png" + id: ship + width: 45 + height: 22 + MouseArea { + id: ma + anchors.fill: parent; + drag.axis: Drag.XandYAxis + drag.target: ship + } + } + Emitter { + group: "engine" + system: particles + emitRate: 200 + lifeSpan: 1000 + size: 10 + endSize: 4 + sizeVariation: 4 + speed: PointDirection { x: -128; xVariation: 32 } + height: ship.height + y: ship.y + x: ship.x + width: 20 + } + Emitter { + group: "shot" + system: particles + emitRate: 32 + lifeSpan: 2000 + enabled: spacePressed + size: 40 + speed: PointDirection { x: 256; } + x: ship.x + ship.width + y: ship.y + ship.height/2 + } + + Text { + color: "white" + anchors.bottom: parent.bottom + text:"Drag the ship, Spacebar to fire." + } +} + diff --git a/examples/particles/affectors/customaffector.qml b/examples/particles/affectors/customaffector.qml new file mode 100644 index 0000000000..3f98cd5b43 --- /dev/null +++ b/examples/particles/affectors/customaffector.qml @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** 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 + +Item { + width: 360 + height: 600 + + Image { + source: "../images/backgroundLeaves.jpg" + anchors.fill: parent + } + ParticleSystem { + id: sys + } + Emitter { + system: sys + width: parent.width + emitRate: 4 + lifeSpan: 14000 + size: 80 + speed: PointDirection { y: 60 } + } + Wander { + system: sys + anchors.fill: parent + anchors.bottomMargin: 100 + xVariance: 60 + pace: 60 + } + + Affector { + system: sys + property real coefficient: 0.1 + property real speed: 1.5 + width: parent.width + height: parent.height - 100 + onAffectParticles: { + /* //Linear movement + if (particle.r == 0) { + particle.r = Math.random() > 0.5 ? -1 : 1; + }else if (particle.r == 1) { + particle.rotation += speed * dt; + if(particle.rotation >= maxAngle) + particle.r = -1; + }else if (particle.r == -1) { + particle.rotation -= speed * dt; + if(particle.rotation <= -1 * maxAngle) + particle.r = 1; + } + */ + //Wobbly movement + for (var i=0; i<particles.length; i++) { + var particle = particles[i]; + if (particle.r == 0.0) { + particle.r = Math.random() + 0.01; + } + particle.rotation += speed * particle.r * dt; + particle.r -= particle.rotation * coefficient; + if (particle.r == 0.0) + particle.r -= particle.rotation * 0.000001; + particle.update = 1; + } + } + } + + Affector {//Custom Friction, adds some 'randomness' + system: sys + //onceOff: true + x: -60 + width: parent.width + 120 + height: 100 + anchors.bottom: parent.bottom + onAffectParticles: { + for (var i=0; i<particles.length; i++) { + var particle = particles[i]; + var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1; + var yslow = dt * pseudoRand * 0.5 + 1; + var xslow = dt * pseudoRand * 0.05 + 1; + if (particle.vy < 1) + particle.vy = 0; + else + particle.vy = (particle.vy / yslow); + if (particle.vx < 1) + particle.vx = 0; + else + particle.vx = (particle.vx / xslow); + particle.update = true; + } + } + } + + ImageParticle { + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite { + source: "../images/realLeaf1.png" + frames: 1 + frameDuration: 1 + to: {"a":1, "b":1, "c":1, "d":1} + }, Sprite { + name: "a" + source: "../images/realLeaf1.png" + frames: 1 + frameDuration: 10000 + }, + Sprite { + name: "b" + source: "../images/realLeaf2.png" + frames: 1 + frameDuration: 10000 + }, + Sprite { + name: "c" + source: "../images/realLeaf3.png" + frames: 1 + frameDuration: 10000 + }, + Sprite { + name: "d" + source: "../images/realLeaf4.png" + frames: 1 + frameDuration: 10000 + } + ] + + width: 100 + height: 100 + x: 20 + y: 20 + z:4 + } +} diff --git a/examples/particles/affectors/friction.qml b/examples/particles/affectors/friction.qml new file mode 100644 index 0000000000..4161fd9f02 --- /dev/null +++ b/examples/particles/affectors/friction.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** 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 + +Item { + width: 360 + height: 600 + + Image { + source: "../images/backgroundLeaves.jpg" + anchors.fill: parent + } + ParticleSystem { id: sys } + Emitter { + system: sys + width: parent.width + emitRate: 4 + lifeSpan: 14000 + size: 80 + speed: PointDirection { y: 160; yVariation: 80; xVariation: 20 } + } + + ImageParticle { + anchors.fill: parent + id: particles + system: sys + sprites: [Sprite { + source: "../images/realLeaf1.png" + frames: 1 + frameDuration: 1 + to: {"a":1, "b":1, "c":1, "d":1} + }, Sprite { + name: "a" + source: "../images/realLeaf1.png" + frames: 1 + frameDuration: 10000 + }, + Sprite { + name: "b" + source: "../images/realLeaf2.png" + frames: 1 + frameDuration: 10000 + }, + Sprite { + name: "c" + source: "../images/realLeaf3.png" + frames: 1 + frameDuration: 10000 + }, + Sprite { + name: "d" + source: "../images/realLeaf4.png" + frames: 1 + frameDuration: 10000 + } + ] + + width: 100 + height: 100 + x: 20 + y: 20 + z:4 + } + Friction { + anchors.fill: parent + anchors.margins: -40 + system: sys + factor: 0.4 + } +} diff --git a/examples/particles/affectors/gravity.qml b/examples/particles/affectors/gravity.qml new file mode 100644 index 0000000000..b90d83e1c8 --- /dev/null +++ b/examples/particles/affectors/gravity.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** 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 + +Item { + id: window + width: 480; height: 480 + Rectangle { + id: sky + anchors.fill: parent + gradient: Gradient { + GradientStop { + position: 0.0 + color: "DeepSkyBlue" + } + GradientStop { + position: 1.0 + color: "SkyBlue" + } + } + } + + Rectangle { + id: ground + width: parent.width * 2 + height: parent.height + y: parent.height/2 + x: -parent.height/2 + transformOrigin: Item.Top + rotation: 0 + gradient: Gradient { + GradientStop { position: 0.0; color: "ForestGreen"; } + GradientStop { position: 1.0; color: "DarkGreen"; } + } + } + + MouseArea { + anchors.fill: parent + onPositionChanged: { + var rot = Math.atan2(mouseY - window.height/2,mouseX - window.width/2) * 180/Math.PI; + ground.rotation = rot; + } + } + + ParticleSystem { id: sys } + Gravity { + system: sys + magnitude: 32 + angle: ground.rotation + 90 + } + Emitter { + system: sys + anchors.centerIn: parent + emitRate: 1 + lifeSpan: 10000 + size: 64 + } + ImageParticle { + anchors.fill: parent + system: sys + source: "../images/realLeaf1.png" + } + +} diff --git a/examples/particles/affectors/groupgoal.qml b/examples/particles/affectors/groupgoal.qml new file mode 100644 index 0000000000..273ec1a30c --- /dev/null +++ b/examples/particles/affectors/groupgoal.qml @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** 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: "black" + + property int score: 0 + Text { + color: "white" + anchors.right: parent.right + text: score + } + + ParticleSystem { + id: particles + anchors.fill: parent + ParticleGroup { + name: "unlit" + duration: 1000 + to: {"lighting":1, "unlit":99} + ImageParticle { + source: "../images/particleA.png" + colorVariation: 0.1 + color: "#2060160f" + } + GroupGoal { + whenCollidingWith: ["lit"] + goalState: "lighting" + jump: true + } + } + ParticleGroup { + name: "lighting" + duration: 100 + to: {"lit":1} + } + ParticleGroup { + name: "lit" + duration: 10000 + onEntered: score++; + TrailEmitter { + id: fireballFlame + group: "flame" + + emitRatePerParticle: 48 + lifeSpan: 200 + emitWidth: 8 + emitHeight: 8 + + size: 24 + sizeVariation: 8 + endSize: 4 + } + + TrailEmitter { + id: fireballSmoke + group: "smoke" + + emitRatePerParticle: 120 + lifeSpan: 2000 + emitWidth: 16 + emitHeight: 16 + + speed: PointDirection {yVariation: 16; xVariation: 16} + acceleration: PointDirection {y: -16} + + size: 24 + sizeVariation: 8 + endSize: 8 + } + } + + ImageParticle { + id: smoke + anchors.fill: parent + groups: ["smoke"] + source: "../images/particle.png" + colorVariation: 0 + color: "#00111111" + } + ImageParticle { + id: pilot + anchors.fill: parent + groups: ["pilot"] + source: "../images/particle.png" + redVariation: 0.01 + blueVariation: 0.4 + color: "#0010004f" + } + ImageParticle { + id: flame + anchors.fill: parent + groups: ["flame", "lit", "lighting"] + source: "../images/particleA.png" + colorVariation: 0.1 + color: "#00ff400f" + } + + Emitter { + height: parent.height/2 + emitRate: 4 + lifeSpan: 4000//TODO: Infinite & kill zone + size: 24 + sizeVariation: 4 + speed: PointDirection {x:120; xVariation: 80; yVariation: 50} + acceleration: PointDirection {y:120} + group: "unlit" + } + + Emitter { + id: flamer + x: 100 + y: 300 + group: "pilot" + emitRate: 80 + lifeSpan: 600 + size: 24 + sizeVariation: 2 + endSize: 0 + speed: PointDirection { y:-100; yVariation: 4; xVariation: 4 } + GroupGoal { + groups: ["unlit"] + goalState: "lit" + jump: true + system: particles + x: -15 + y: -55 + height: 75 + width: 30 + shape: MaskShape {source: "../images/matchmask.png"} + } + } + //Click to enflame + GroupGoal { + groups: ["unlit"] + goalState: "lighting" + jump: true + enabled: ma.pressed + width: 18 + height: 18 + x: ma.mouseX - width/2 + y: ma.mouseY - height/2 + } + MouseArea { + id: ma + anchors.fill: parent + } + } +} diff --git a/examples/particles/affectors/move.qml b/examples/particles/affectors/move.qml new file mode 100644 index 0000000000..f290173ca8 --- /dev/null +++ b/examples/particles/affectors/move.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** 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: ["A"] + anchors.fill: parent + source: "../images/star.png" + color:"#FF1010" + redVariation: 0.8 + } + + Emitter { + group: "A" + emitRate: 100 + lifeSpan: 2800 + size: 32 + sizeVariation: 8 + speed: PointDirection{ x: 66; xVariation: 20 } + width: 80 + height: 80 + } + + Affector { + groups: ["A"] + x: 120 + width: 80 + height: 80 + once: true + position: PointDirection { x: 120; } + } + + ImageParticle { + groups: ["B"] + anchors.fill: parent + source: "../images/star.png" + color:"#10FF10" + greenVariation: 0.8 + } + + Emitter { + group: "B" + emitRate: 100 + lifeSpan: 2800 + size: 32 + sizeVariation: 8 + speed: PointDirection{ x: 240; xVariation: 60 } + y: 260 + width: 10 + height: 10 + } + + Affector { + groups: ["B"] + x: 120 + y: 240 + width: 80 + height: 80 + once: true + speed: AngleDirection { angleVariation:360; magnitude: 72 } + } + + ImageParticle { + groups: ["C"] + anchors.fill: parent + source: "../images/star.png" + color:"#1010FF" + blueVariation: 0.8 + } + + Emitter { + group: "C" + y: 400 + emitRate: 100 + lifeSpan: 2800 + size: 32 + sizeVariation: 8 + speed: PointDirection{ x: 80; xVariation: 10 } + acceleration: PointDirection { y: 10; x: 20; } + width: 80 + height: 80 + } + + Affector { + groups: ["C"] + x: 120 + y: 400 + width: 80 + height: 120 + once: true + relative: false + acceleration: PointDirection { y: -80; } + } + + } +} diff --git a/examples/particles/affectors/spritegoal.qml b/examples/particles/affectors/spritegoal.qml new file mode 100644 index 0000000000..1ea61442aa --- /dev/null +++ b/examples/particles/affectors/spritegoal.qml @@ -0,0 +1,212 @@ +/**************************************************************************** +** +** 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 + +Item { + id: root + width: 360 + height: 540 + MouseArea { + id: ma + anchors.fill: parent + } + + ParticleSystem { id: sys } + Image { + source: "../images/finalfrontier.png" + transformOrigin: Item.Center + anchors.centerIn: parent + smooth: true + NumberAnimation on rotation { + from: 0 + to: 360 + duration: 200000 + loops: Animation.Infinite + } + + } + ImageParticle { + system: sys + groups: ["starfield"] + source: "../images/star.png" + colorVariation: 0.3 + color: "white" + } + Emitter { + id: starField + system: sys + group: "starfield" + + emitRate: 80 + lifeSpan: 2500 + + anchors.centerIn: parent + + //acceleration: AngledDirection {angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent speed? + acceleration: PointDirection { xVariation: 200; yVariation: 200; } + + size: 0 + endSize: 80 + sizeVariation: 10 + } + Emitter { + system: sys + group: "meteor" + emitRate: 12 + lifeSpan: 5000 + acceleration: PointDirection { xVariation: 80; yVariation: 80; } + size: 15 + endSize: 300 + anchors.centerIn: parent + } + ImageParticle { + system: sys + groups: ["meteor"] + sprites:[Sprite { + id: spinState + name: "spinning" + source: "../images/meteor.png" + frames: 35 + frameDuration: 40 + randomStart: true + to: {"explode":0, "spinning":1} + },Sprite { + name: "explode" + source: "../images/_explo.png" + frames: 22 + frameDuration: 40 + to: {"nullFrame":1} + },Sprite {//Not sure if this is needed, but seemed easiest + name: "nullFrame" + source: "../images/nullRock.png" + frames: 1 + frameDuration: 1000 + } + ] + } + SpriteGoal { + groups: ["meteor"] + system: sys + goalState: "explode" + jump: true + anchors.centerIn: holder//A bug in affectors currently isn't compensating for relative x,y. when that's fixed this can just anchors.fill: rocketShip + width: 60 + height: 60 + } + Image { + id: rocketShip + source: "../images/rocket.png" + smooth: true + anchors.centerIn: holder + rotation: (circle.percent+0.25) * 360 + z: 2 + } + Item { + id: holder + x: circle.x - Math.sin(circle.percent * 6.28316530714)*200 + y: circle.y + Math.cos(circle.percent * 6.28316530714)*200 + z: 1 + } + + Item { + id: circle + x: root.width / 1.2 + y: root.height / 1.7 + property real percent: 0 + + SequentialAnimation on percent { + id: circleAnim1 + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 4000 + from: 1 + to: 0 + } + + } + } + + ImageParticle { + z:0 + system: sys + groups: ["exhaust"] + source: "../images/particle4.png" + + color: "orange" + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "red" + duration: 1000 + } + } + + colorVariation: 0.2 + } + + Emitter { + id: trailsNormal2 + system: sys + group: "exhaust" + + emitRate: 300 + lifeSpan: 500 + + y: holder.y + x: holder.x + + speed: PointDirection { xVariation: 40; yVariation: 40; } + speedFromMovement: 16 + + acceleration: PointDirection { xVariation: 10; yVariation: 10; } + + size: 4 + sizeVariation: 4 + } +} diff --git a/examples/particles/affectors/turbulence.qml b/examples/particles/affectors/turbulence.qml new file mode 100644 index 0000000000..f3ad13431f --- /dev/null +++ b/examples/particles/affectors/turbulence.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** 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: "#222222" + id: root + Image { + source: "../images/candle.png" + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottomMargin: -8 + anchors.horizontalCenterOffset: 2 + } + ParticleSystem { + id: ps + } + MouseArea { + anchors.fill: parent + onClicked: turb.enabled = !turb.enabled + } + + Turbulence { + id: turb + system: ps + enabled: true + height: (parent.height / 2) + width: parent.width / 2 + x: parent. width / 4 + anchors.fill: parent + strength: 32 + } + + ImageParticle { + groups: ["smoke"] + system: ps + source: "../images/particle.png" + color: "#11111111" + colorVariation: 0 + } + ImageParticle { + groups: ["flame"] + system: ps + source: "../images/particle.png" + color: "#11ff400f" + colorVariation: 0.1 + } + Emitter { + anchors.centerIn: parent + system: ps + group: "flame" + + emitRate: 120 + lifeSpan: 1200 + size: 20 + endSize: 10 + sizeVariation: 10 + acceleration: PointDirection { y: -40 } + speed: AngleDirection { angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 } + } + TrailEmitter { + id: smoke1 + width: root.width + height: root.height/2 - 20 + system: ps + group: "smoke" + follow: "flame" + + emitRatePerParticle: 1 + lifeSpan: 2400 + lifeSpanVariation: 400 + size: 16 + endSize: 8 + sizeVariation: 8 + acceleration: PointDirection { y: -40 } + speed: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 } + } + TrailEmitter { + id: smoke2 + width: root.width + height: root.height/2 - 40 + system: ps + group: "smoke" + follow: "flame" + + emitRatePerParticle: 4 + lifeSpan: 2400 + size: 36 + endSize: 24 + sizeVariation: 12 + acceleration: PointDirection { y: -40 } + speed: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 } + } +} diff --git a/examples/particles/affectors/wander.qml b/examples/particles/affectors/wander.qml new file mode 100644 index 0000000000..31a0b4a796 --- /dev/null +++ b/examples/particles/affectors/wander.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Particles 2.0 +import "../exampleslauncher/content" as UI + +Rectangle { + width: 360 + height: 540 + ParticleSystem { id: particles } + ImageParticle { + system: particles + sprites: Sprite { + name: "snow" + source: "../images/snowflake.png" + frames: 51 + frameDuration: 40 + frameDurationVariation: 8 + } + } + + Wander { + id: wanderer + system: particles + anchors.fill: parent + xVariance: 360/(wanderer.affectedParameter+1); + pace: 100*(wanderer.affectedParameter+1); + } + + Emitter { + system: particles + emitRate: 20 + lifeSpan: 7000 + speed: PointDirection { y:80; yVariation: 40; } + acceleration: PointDirection { y: 4 } + size: 20 + sizeVariation: 10 + width: parent.width + height: 100 + } + Row { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + UI.Button { + text:"dx/dt" + onClicked: wanderer.affectedParameter = Wander.Position; + } + UI.Button { + text:"dv/dt" + onClicked: wanderer.affectedParameter = Wander.Velocity; + } + UI.Button { + text:"da/dt" + onClicked: wanderer.affectedParameter = Wander.Acceleration; + } + } +} diff --git a/examples/particles/customparticle/blurparticles.qml b/examples/particles/customparticle/blurparticles.qml new file mode 100644 index 0000000000..3d72425655 --- /dev/null +++ b/examples/particles/customparticle/blurparticles.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 { + color: "white" + width: 240 + height: 360 + ParticleSystem { + id: sys + } + Emitter { + system:sys + height: parent.height + emitRate: 1 + lifeSpan: 12000 + speed: 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/fragmentshader.qml b/examples/particles/customparticle/fragmentshader.qml new file mode 100644 index 0000000000..34acb1bd7c --- /dev/null +++ b/examples/particles/customparticle/fragmentshader.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** 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 + speed: 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 speed 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 new file mode 100644 index 0000000000..94e5123a0c --- /dev/null +++ b/examples/particles/customparticle/imagecolors.qml @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** 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/emitters/burstandpulse.qml b/examples/particles/emitters/burstandpulse.qml new file mode 100644 index 0000000000..1b1c2a60c9 --- /dev/null +++ b/examples/particles/emitters/burstandpulse.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 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 + speed: AngleDirection{magnitude: 64; angleVariation: 360} + size: 24 + sizeVariation: 8 + } +} diff --git a/examples/particles/emitters/customemitter.qml b/examples/particles/emitters/customemitter.qml new file mode 100644 index 0000000000..757c836106 --- /dev/null +++ b/examples/particles/emitters/customemitter.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** 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 + onEmitParticles: { + for (var i=0; i<particles.length; i++) { + var particle = particles[i]; + particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24)); + var theta = Math.floor(Math.random() * 6.0) / 6.0; + theta *= 2.0*Math.PI; + theta += sys.convert(sys.petalRotation); + particle.initialVX = petalLength * Math.cos(theta); + particle.initialVY = petalLength * Math.sin(theta); + particle.initialAX = particle.initialVX * -0.5; + particle.initialAY = particle.initialVY * -0.5; + } + } + } + + ImageParticle { + source: "../images/particle4.png" + alpha: 0.0 + redVariation: 0.6 + color: "white" + } +} diff --git a/examples/particles/emitters/emitmask.qml b/examples/particles/emitters/emitmask.qml new file mode 100644 index 0000000000..9c02f6a213 --- /dev/null +++ b/examples/particles/emitters/emitmask.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** 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 { + width: 300 + height: 300 + anchors.centerIn: parent + + ImageParticle { + source: "../images/particle.png" + z: 2 + anchors.fill: parent + color: "#336666CC" + colorVariation: 0.0 + } + + Emitter { + anchors.fill: parent + emitRate: 6000 + lifeSpan: 720 + size: 10 + shape: MaskShape { + source: "../images/starfish_mask.png" + } + } + + } +} diff --git a/examples/particles/emitters/maximumemitted.qml b/examples/particles/emitters/maximumemitted.qml new file mode 100644 index 0000000000..6dbdf8db61 --- /dev/null +++ b/examples/particles/emitters/maximumemitted.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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: "black" + width: 360 + height: 540 + ParticleSystem { + id: sys + onEmptyChanged: if (empty) sys.pause(); + } + + ImageParticle { + system: sys + id: cp + source: "../images/particle.png" + colorVariation: 0.4 + color: "#000000FF" + } + + Emitter { + //burst on click + id: bursty + system: sys + enabled: ma.pressed + x: ma.mouseX + y: ma.mouseY + emitRate: 16000 + maximumEmitted: 4000 + acceleration: AngleDirection {angleVariation: 360; magnitude: 360; } + size: 8 + endSize: 16 + sizeVariation: 4 + } + + MouseArea { + anchors.fill: parent + onPressed: sys.resume() + id: ma + } +} diff --git a/examples/particles/emitters/shapeanddirection.qml b/examples/particles/emitters/shapeanddirection.qml new file mode 100644 index 0000000000..43623427b6 --- /dev/null +++ b/examples/particles/emitters/shapeanddirection.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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: 540 + color: "black" + Image { + anchors.fill: parent + source: "../images/portal_bg.png" + } + + ParticleSystem { + id: particles + } + + ImageParticle { + groups: ["center","edge"] + anchors.fill: parent + system: particles + source: "../images/particle.png" + colorVariation: 0.1 + color: "#009999FF" + } + + Emitter { + anchors.fill: parent + group: "center" + system: particles + emitRate: 400 + lifeSpan: 2000 + size: 20 + sizeVariation: 2 + endSize: 0 + shape: EllipseShape {fill: false} + speed: TargetDirection { + targetX: root.width/2 + targetY: root.height/2 + proportionalMagnitude: true + magnitude: 0.5 + } + } + + Emitter { + anchors.fill: parent + group: "edge" + startTime: 2000 + system: particles + emitRate: 2000 + lifeSpan: 2000 + size: 28 + sizeVariation: 2 + endSize: 16 + shape: EllipseShape {fill: false} + speed: TargetDirection { + targetX: root.width/2 + targetY: root.height/2 + proportionalMagnitude: true + magnitude: 0.1 + magnitudeVariation: 0.1 + } + acceleration: TargetDirection { + targetX: root.width/2 + targetY: root.height/2 + targetVariation: 200 + proportionalMagnitude: true + magnitude: 0.1 + magnitudeVariation: 0.1 + } + } +} diff --git a/examples/particles/emitters/timedgroupchanges.qml b/examples/particles/emitters/timedgroupchanges.qml new file mode 100644 index 0000000000..699e7eb066 --- /dev/null +++ b/examples/particles/emitters/timedgroupchanges.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** 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 + ParticleGroup { + name: "fire" + duration: 2000 + durationVariation: 2000 + to: {"splode":1} + } + ParticleGroup { + name: "splode" + duration: 400 + to: {"dead":1} + TrailEmitter { + group: "works" + emitRatePerParticle: 100 + lifeSpan: 1000 + maximumEmitted: 1200 + size: 8 + speed: AngleDirection {angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;} + acceleration: PointDirection {y:100; yVariation: 20} + } + } + ParticleGroup { + name: "dead" + duration: 1000 + Affector { + once: true + onAffected: worksEmitter.burst(400,x,y) + } + } + + 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 + speed: PointDirection {y:-100;} + size: 32 + } + + Emitter { + id: worksEmitter + group: "works" + enabled: false + emitRate: 100 + lifeSpan: 1600 + maximumEmitted: 6400 + size: 8 + speed: 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/emitters/trailemitter.qml b/examples/particles/emitters/trailemitter.qml new file mode 100644 index 0000000000..e896329ca1 --- /dev/null +++ b/examples/particles/emitters/trailemitter.qml @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** 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: 540 + color: "black" + + ParticleSystem { + id: particles + } + + ImageParticle { + id: smoke + system: particles + anchors.fill: parent + groups: ["A", "B"] + source: "../images/particle.png" + colorVariation: 0 + color: "#00111111" + } + ImageParticle { + id: flame + anchors.fill: parent + system: particles + groups: ["C", "D"] + source: "../images/particle.png" + colorVariation: 0.1 + color: "#00ff400f" + } + + Emitter { + id: fire + system: particles + group: "C" + + y: parent.height + width: parent.width + + emitRate: 350 + lifeSpan: 3500 + + acceleration: PointDirection { y: -17; xVariation: 3 } + speed: PointDirection {xVariation: 3} + + size: 24 + sizeVariation: 8 + endSize: 4 + } + + TrailEmitter { + id: fireSmoke + group: "B" + system: particles + follow: "C" + width: root.width + height: root.height - 68 + + emitRatePerParticle: 1 + lifeSpan: 2000 + + speed: PointDirection {y:-17*6; yVariation: -17; xVariation: 3} + acceleration: PointDirection {xVariation: 3} + + size: 36 + sizeVariation: 8 + endSize: 16 + } + + TrailEmitter { + id: fireballFlame + anchors.fill: parent + system: particles + group: "D" + follow: "E" + + emitRatePerParticle: 120 + lifeSpan: 180 + emitWidth: TrailEmitter.ParticleSize + emitHeight: TrailEmitter.ParticleSize + emitShape: EllipseShape{} + + size: 16 + sizeVariation: 4 + endSize: 4 + } + + TrailEmitter { + id: fireballSmoke + anchors.fill: parent + system: particles + group: "A" + follow: "E" + + emitRatePerParticle: 128 + lifeSpan: 2400 + emitWidth: TrailEmitter.ParticleSize + emitHeight: TrailEmitter.ParticleSize + emitShape: EllipseShape{} + + speed: PointDirection {yVariation: 16; xVariation: 16} + acceleration: PointDirection {y: -16} + + size: 24 + sizeVariation: 8 + endSize: 8 + } + + Emitter { + id: balls + system: particles + group: "E" + + y: parent.height + width: parent.width + + emitRate: 2 + lifeSpan: 7000 + + speed: PointDirection {y:-17*4*2; xVariation: 6*6} + acceleration: PointDirection {y: 17*2; xVariation: 6*6} + + size: 8 + sizeVariation: 4 + } + + Turbulence { //A bit of turbulence makes the smoke look better + anchors.fill: parent + groups: ["A","B"] + strength: 32 + system: particles + } +} + diff --git a/examples/particles/emitters/velocityfrommotion.qml b/examples/particles/emitters/velocityfrommotion.qml new file mode 100644 index 0000000000..7ad2b4d6c4 --- /dev/null +++ b/examples/particles/emitters/velocityfrommotion.qml @@ -0,0 +1,311 @@ +/**************************************************************************** +** +** 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 + + height: 540 + width: 360 + + gradient: Gradient { + GradientStop { position: 0; color: "#000020" } + GradientStop { position: 1; color: "#000000" } + } + + MouseArea { + id: mouseArea + anchors.fill: root + } + + ParticleSystem { id: sys1 } + ImageParticle { + system: sys1 + source: "../images/particle.png" + color: "cyan" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "cyan" + to: "magenta" + duration: 1000 + } + ColorAnimation { + from: "magenta" + to: "blue" + duration: 2000 + } + ColorAnimation { + from: "blue" + to: "violet" + duration: 2000 + } + ColorAnimation { + from: "violet" + to: "cyan" + duration: 2000 + } + } + colorVariation: 0.3 + } + Emitter { + id: trailsNormal + system: sys1 + + emitRate: 500 + lifeSpan: 2000 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle.cx + + speed: PointDirection {xVariation: 4; yVariation: 4;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + speedFromMovement: 8 + + size: 8 + sizeVariation: 4 + } + ParticleSystem { id: sys2 } + ImageParticle { + color: "cyan" + system: sys2 + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "magenta" + to: "cyan" + duration: 1000 + } + ColorAnimation { + from: "cyan" + to: "magenta" + duration: 2000 + } + } + colorVariation: 0.5 + source: "../images/star.png" + } + Emitter { + id: trailsStars + system: sys2 + + emitRate: 100 + lifeSpan: 2200 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle.cx + + speed: PointDirection {xVariation: 4; yVariation: 4;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + speedFromMovement: 8 + + size: 22 + sizeVariation: 4 + } + ParticleSystem { id: sys3; } + ImageParticle { + source: "../images/particle.png" + system: sys3 + color: "orange" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "red" + to: "green" + duration: 2000 + } + ColorAnimation { + from: "green" + to: "red" + duration: 2000 + } + } + + colorVariation: 0.2 + + } + Emitter { + id: trailsNormal2 + system: sys3 + + emitRate: 300 + lifeSpan: 2000 + + y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx + + speedFromMovement: 16 + + speed: PointDirection {xVariation: 4; yVariation: 4;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + + size: 12 + sizeVariation: 4 + } + ParticleSystem { id: sys4; } + ImageParticle { + system: sys4 + source: "../images/star.png" + color: "green" + alpha: 0 + SequentialAnimation on color { + loops: Animation.Infinite + ColorAnimation { + from: "green" + to: "red" + duration: 2000 + } + ColorAnimation { + from: "red" + to: "green" + duration: 2000 + } + } + + colorVariation: 0.5 + } + Emitter { + id: trailsStars2 + system: sys4 + + emitRate: 50 + lifeSpan: 2200 + + + y: mouseArea.pressed ? mouseArea.mouseY : circle2.cy + x: mouseArea.pressed ? mouseArea.mouseX : circle2.cx + + speedFromMovement: 16 + speed: PointDirection {xVariation: 2; yVariation: 2;} + acceleration: PointDirection {xVariation: 10; yVariation: 10;} + + size: 22 + sizeVariation: 4 + } + + + + color: "white" + + Item { + id: circle + //anchors.fill: parent + property real radius: 0 + property real dx: root.width / 2 + property real dy: root.height / 2 + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 1000 + from: 1 + to: 0 + loops: 8 + } + NumberAnimation { + duration: 1000 + from: 0 + to: 1 + loops: 8 + } + + } + + SequentialAnimation on radius { + loops: Animation.Infinite + running: true + NumberAnimation { + duration: 4000 + from: 0 + to: 100 + } + NumberAnimation { + duration: 4000 + from: 100 + to: 0 + } + } + } + + Item { + id: circle3 + property real radius: 100 + property real dx: root.width / 2 + property real dy: root.height / 2 + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { from: 0.0; to: 1 ; duration: 10000; } + } + } + + Item { + id: circle2 + property real radius: 30 + property real dx: circle3.cx + property real dy: circle3.cy + property real cx: radius * Math.sin(percent*6.283185307179) + dx + property real cy: radius * Math.cos(percent*6.283185307179) + dy + property real percent: 0 + + SequentialAnimation on percent { + loops: Animation.Infinite + running: true + NumberAnimation { from: 0.0; to: 1 ; duration: 1000; } + } + } + +} diff --git a/examples/particles/exampleslauncher/content/Button.qml b/examples/particles/exampleslauncher/content/Button.qml new file mode 100644 index 0000000000..e51a9be003 --- /dev/null +++ b/examples/particles/exampleslauncher/content/Button.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 + +Rectangle { + id: container + + property string text: "Button" + signal clicked + + width: buttonLabel.width + 20; height: buttonLabel.height + 20 + smooth: true + property color myCol: "#999999" + border { width: 1; color: Qt.darker(myCol) } + radius: 8 + + gradient: Gradient { + GradientStop { + position: 0.0 + color: { + if (mouseArea.pressed) + return Qt.darker(myCol) + else + return Qt.lighter(myCol) + } + } + GradientStop { position: 1.0; color: myCol } + } + + MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() } + + Text { + id: buttonLabel; text: container.text; anchors.centerIn: container; color: "black"; font.pixelSize: 24 + } +} diff --git a/examples/particles/exampleslauncher/content/Shell.qml b/examples/particles/exampleslauncher/content/Shell.qml new file mode 100644 index 0000000000..afab77485f --- /dev/null +++ b/examples/particles/exampleslauncher/content/Shell.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 + +Loader { + id: ldr + visible: false + focus: visible + onVisibleChanged: source = "" + opacity: visible?1:0 + Behavior on opacity {NumberAnimation {}} + + function setDemo(str) { + visible = true; + source = str; + } + Image {//TODO: Augment with PARTICLES + z: 1 + source: "../../images/launcherIcons/close.png" + MouseArea { + anchors.fill: parent + onClicked: ldr.visible = false; + } + } + Rectangle { + z: -1 + anchors.fill: parent + color:"black" + Text { + color: "white" + anchors.centerIn: parent + text: ldr.Status == Loader.Error ? "Error :(" : "Loading..." + } + MouseArea { + id: graball + anchors.fill: parent + onClicked:; + } + } +} diff --git a/examples/particles/exampleslauncher/content/launcher.js b/examples/particles/exampleslauncher/content/launcher.js new file mode 100644 index 0000000000..a296dbd6a6 --- /dev/null +++ b/examples/particles/exampleslauncher/content/launcher.js @@ -0,0 +1,8 @@ +function nameFromPath(path){ + var ret = path.split('/'); + return ret[ret.length-1].split('.')[0]; +} +function iconFromPath(path){ + var ret = path.split('/'); + return "../images/launcherIcons/" + ret[ret.length-1].split('.')[0] + ".png"; +} diff --git a/examples/particles/exampleslauncher/exampleslauncher.qml b/examples/particles/exampleslauncher/exampleslauncher.qml new file mode 100644 index 0000000000..22914343ba --- /dev/null +++ b/examples/particles/exampleslauncher/exampleslauncher.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 +import "content/launcher.js" as Util +import "content" + +Rectangle { + color: "black" + width: 360 + height: 600 + Shell { + z: 1 + id: shell + anchors.fill: parent + } + + VisualDataModel {//TODO: Transitions between modes (and a second mode...) + id: vdm + model: [ + "../../affectors/attractor.qml", + "../../affectors/customaffector.qml", + "../../affectors/groupgoal.qml", + "../../affectors/spritegoal.qml", + "../../affectors/turbulence.qml", + "../../affectors/wander.qml", + "../../customparticle/blurparticles.qml", + "../../customparticle/fragmentshader.qml", + "../../customparticle/imagecolors.qml", + "../../emitters/customemitter.qml", + "../../emitters/emitmask.qml", + "../../emitters/maximumemitted.qml", + "../../emitters/shapeanddirection.qml", + "../../emitters/timedgroupchanges.qml", + "../../emitters/trailemitter.qml", + "../../emitters/velocityfrommotion.qml", + "../../imageparticle/allatonce.qml", + "../../imageparticle/colortable.qml", + "../../imageparticle/deformation.qml", + "../../imageparticle/rotation.qml", + "../../imageparticle/sprites.qml", + "../../itemparticle/delegates.qml", + "../../itemparticle/particleview.qml", + "../../simple/dynamicemitters.qml", + "../../simple/multiplepainters.qml", + "../../simple/startstop.qml", + "../../plasmapatrol/plasmapatrol.qml" + ] + delegate: Rectangle { + color: "white" + width: 96 + height: 96 + Image { + width: 72 + height: 72 + anchors.centerIn: parent + source: Util.iconFromPath(modelData) + } + Text { + text: Util.nameFromPath(modelData) + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 8 + } + MouseArea { + anchors.fill: parent + onClicked: shell.setDemo(modelData) + } + } + } + + GridView { + anchors.fill: parent + cellWidth: 120 + cellHeight: 120 + model: vdm + } +} diff --git a/examples/particles/imageparticle/allatonce.qml b/examples/particles/imageparticle/allatonce.qml new file mode 100644 index 0000000000..fbc634ec9a --- /dev/null +++ b/examples/particles/imageparticle/allatonce.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 { + sprites: [ + Sprite { + name: "bear" + source: "../images/bear_tiles.png" + frames: 13 + frameDuration: 120 + } + ] + colorVariation: 0.5 + rotationSpeedVariation: 360 + system: sys + colorTable: "../trails/../images/colortable.png" + } + + Friction { + factor: 0.1 + system: sys + } + + Emitter { + system: sys + anchors.centerIn: parent + id: particles + emitRate: 200 + lifeSpan: 6000 + speed: 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/colored.qml b/examples/particles/imageparticle/colored.qml new file mode 100644 index 0000000000..ac760b6219 --- /dev/null +++ b/examples/particles/imageparticle/colored.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" + 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 + speed: 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 new file mode 100644 index 0000000000..623029dae0 --- /dev/null +++ b/examples/particles/imageparticle/colortable.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.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 + } + + speedFromMovement: 20 + + speed: PointDirection { xVariation: 5; yVariation: 5;} + acceleration: PointDirection { xVariation: 5; yVariation: 5;} + + size: 16 + //endSize: 8 + //sizeVariation: 8 + } +} diff --git a/examples/particles/imageparticle/deformation.qml b/examples/particles/imageparticle/deformation.qml new file mode 100644 index 0000000000..e282927e78 --- /dev/null +++ b/examples/particles/imageparticle/deformation.qml @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** 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 + rotationSpeed: 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" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitB + x: 400 + y: 240 + system: sys + enabled: false + group: "goingLeft" + speed: PointDirection { x: -100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } + Emitter { + id: emitC + x: 0 + y: 360 + system: sys + enabled: false + group: "goingDown" + speed: PointDirection { x: 100 } + lifeSpan: 4000 + emitRate: 1 + size: 128 + } +} diff --git a/examples/particles/imageparticle/rotation.qml b/examples/particles/imageparticle/rotation.qml new file mode 100644 index 0000000000..3a75c379ed --- /dev/null +++ b/examples/particles/imageparticle/rotation.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 + speed: 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 new file mode 100644 index 0000000000..27e08322d9 --- /dev/null +++ b/examples/particles/imageparticle/sharing.qml @@ -0,0 +1,199 @@ +/**************************************************************************** +** +** 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 + speed: 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 new file mode 100644 index 0000000000..0fe4f31ea3 --- /dev/null +++ b/examples/particles/imageparticle/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 + + SpriteImage { + sprites: Sprite { + name: "bear" + source: "../images/bear_tiles.png" + frames: 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" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "angry" + source: "../images/starfish_0.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "angry": 1} + }, Sprite { + name: "silly" + source: "../images/starfish_2.png" + frames: 1 + frameDuration: 260 + to: {"happy": 1, "silly": 1, "noticedbear": 0} + }, Sprite { + name: "noticedbear" + source: "../images/starfish_3.png" + frames: 1 + frameDuration: 2600 + }] + } + + Emitter { + system: sys + emitRate: 2 + lifeSpan: 10000 + speed: 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/images/_explo.png b/examples/particles/images/_explo.png Binary files differnew file mode 100644 index 0000000000..4297245d49 --- /dev/null +++ b/examples/particles/images/_explo.png diff --git a/examples/particles/images/backgroundLeaves.jpg b/examples/particles/images/backgroundLeaves.jpg Binary files differnew file mode 100755 index 0000000000..08be16751d --- /dev/null +++ b/examples/particles/images/backgroundLeaves.jpg diff --git a/examples/particles/images/bear_tiles.png b/examples/particles/images/bear_tiles.png Binary files differnew file mode 100644 index 0000000000..6bbb2a9b6d --- /dev/null +++ b/examples/particles/images/bear_tiles.png diff --git a/examples/particles/images/candle.png b/examples/particles/images/candle.png Binary files differnew file mode 100644 index 0000000000..8fa3193719 --- /dev/null +++ b/examples/particles/images/candle.png diff --git a/examples/particles/images/colortable.png b/examples/particles/images/colortable.png Binary files differnew file mode 100644 index 0000000000..a62ceeb4a0 --- /dev/null +++ b/examples/particles/images/colortable.png diff --git a/examples/particles/images/finalfrontier.png b/examples/particles/images/finalfrontier.png Binary files differnew file mode 100644 index 0000000000..2ba1815230 --- /dev/null +++ b/examples/particles/images/finalfrontier.png diff --git a/examples/particles/images/flower.png b/examples/particles/images/flower.png Binary files differnew file mode 100644 index 0000000000..b5c606210e --- /dev/null +++ b/examples/particles/images/flower.png diff --git a/examples/particles/images/launcherIcons/allatonce.png b/examples/particles/images/launcherIcons/allatonce.png Binary files differnew file mode 100644 index 0000000000..b61d2d50d8 --- /dev/null +++ b/examples/particles/images/launcherIcons/allatonce.png diff --git a/examples/particles/images/launcherIcons/attractor.png b/examples/particles/images/launcherIcons/attractor.png Binary files differnew file mode 100644 index 0000000000..4bd8040c3b --- /dev/null +++ b/examples/particles/images/launcherIcons/attractor.png diff --git a/examples/particles/images/launcherIcons/blurparticles.png b/examples/particles/images/launcherIcons/blurparticles.png Binary files differnew file mode 100644 index 0000000000..4337f979cb --- /dev/null +++ b/examples/particles/images/launcherIcons/blurparticles.png diff --git a/examples/particles/images/launcherIcons/close.png b/examples/particles/images/launcherIcons/close.png Binary files differnew file mode 100644 index 0000000000..c37714ee8f --- /dev/null +++ b/examples/particles/images/launcherIcons/close.png diff --git a/examples/particles/images/launcherIcons/colortable.png b/examples/particles/images/launcherIcons/colortable.png Binary files differnew file mode 100644 index 0000000000..8841ea30f9 --- /dev/null +++ b/examples/particles/images/launcherIcons/colortable.png diff --git a/examples/particles/images/launcherIcons/customaffector.png b/examples/particles/images/launcherIcons/customaffector.png Binary files differnew file mode 100644 index 0000000000..d02e7918fa --- /dev/null +++ b/examples/particles/images/launcherIcons/customaffector.png diff --git a/examples/particles/images/launcherIcons/customemitter.png b/examples/particles/images/launcherIcons/customemitter.png Binary files differnew file mode 100644 index 0000000000..6d492573d1 --- /dev/null +++ b/examples/particles/images/launcherIcons/customemitter.png diff --git a/examples/particles/images/launcherIcons/deformation.png b/examples/particles/images/launcherIcons/deformation.png Binary files differnew file mode 100644 index 0000000000..d1b722df01 --- /dev/null +++ b/examples/particles/images/launcherIcons/deformation.png diff --git a/examples/particles/images/launcherIcons/delegates.png b/examples/particles/images/launcherIcons/delegates.png Binary files differnew file mode 100644 index 0000000000..929414cd0e --- /dev/null +++ b/examples/particles/images/launcherIcons/delegates.png diff --git a/examples/particles/images/launcherIcons/dynamicemitters.png b/examples/particles/images/launcherIcons/dynamicemitters.png Binary files differnew file mode 100644 index 0000000000..0cdef9d21e --- /dev/null +++ b/examples/particles/images/launcherIcons/dynamicemitters.png diff --git a/examples/particles/images/launcherIcons/emitmask.png b/examples/particles/images/launcherIcons/emitmask.png Binary files differnew file mode 100644 index 0000000000..e943a4adb9 --- /dev/null +++ b/examples/particles/images/launcherIcons/emitmask.png diff --git a/examples/particles/images/launcherIcons/flickr.png b/examples/particles/images/launcherIcons/flickr.png Binary files differnew file mode 100644 index 0000000000..4de2650280 --- /dev/null +++ b/examples/particles/images/launcherIcons/flickr.png diff --git a/examples/particles/images/launcherIcons/fragmentshader.png b/examples/particles/images/launcherIcons/fragmentshader.png Binary files differnew file mode 100644 index 0000000000..7c6de498d5 --- /dev/null +++ b/examples/particles/images/launcherIcons/fragmentshader.png diff --git a/examples/particles/images/launcherIcons/gridsplosion.png b/examples/particles/images/launcherIcons/gridsplosion.png Binary files differnew file mode 100644 index 0000000000..ec75453df6 --- /dev/null +++ b/examples/particles/images/launcherIcons/gridsplosion.png diff --git a/examples/particles/images/launcherIcons/groupgoal.png b/examples/particles/images/launcherIcons/groupgoal.png Binary files differnew file mode 100644 index 0000000000..69c6f64e54 --- /dev/null +++ b/examples/particles/images/launcherIcons/groupgoal.png diff --git a/examples/particles/images/launcherIcons/imagecolors.png b/examples/particles/images/launcherIcons/imagecolors.png Binary files differnew file mode 100644 index 0000000000..0ff13a346e --- /dev/null +++ b/examples/particles/images/launcherIcons/imagecolors.png diff --git a/examples/particles/images/launcherIcons/list.png b/examples/particles/images/launcherIcons/list.png Binary files differnew file mode 100644 index 0000000000..bc13263cff --- /dev/null +++ b/examples/particles/images/launcherIcons/list.png diff --git a/examples/particles/images/launcherIcons/maximumemitted.png b/examples/particles/images/launcherIcons/maximumemitted.png Binary files differnew file mode 100644 index 0000000000..4ef0435991 --- /dev/null +++ b/examples/particles/images/launcherIcons/maximumemitted.png diff --git a/examples/particles/images/launcherIcons/multiplepainters.png b/examples/particles/images/launcherIcons/multiplepainters.png Binary files differnew file mode 100644 index 0000000000..a28e3c4f02 --- /dev/null +++ b/examples/particles/images/launcherIcons/multiplepainters.png diff --git a/examples/particles/images/launcherIcons/package.png b/examples/particles/images/launcherIcons/package.png Binary files differnew file mode 100644 index 0000000000..eba8951c26 --- /dev/null +++ b/examples/particles/images/launcherIcons/package.png diff --git a/examples/particles/images/launcherIcons/particleview.png b/examples/particles/images/launcherIcons/particleview.png Binary files differnew file mode 100644 index 0000000000..a74f9a0340 --- /dev/null +++ b/examples/particles/images/launcherIcons/particleview.png diff --git a/examples/particles/images/launcherIcons/plasmapatrol.png b/examples/particles/images/launcherIcons/plasmapatrol.png Binary files differnew file mode 100644 index 0000000000..fda852b420 --- /dev/null +++ b/examples/particles/images/launcherIcons/plasmapatrol.png diff --git a/examples/particles/images/launcherIcons/remove.png b/examples/particles/images/launcherIcons/remove.png Binary files differnew file mode 100644 index 0000000000..c37714ee8f --- /dev/null +++ b/examples/particles/images/launcherIcons/remove.png diff --git a/examples/particles/images/launcherIcons/rotation.png b/examples/particles/images/launcherIcons/rotation.png Binary files differnew file mode 100644 index 0000000000..6a8dbea236 --- /dev/null +++ b/examples/particles/images/launcherIcons/rotation.png diff --git a/examples/particles/images/launcherIcons/samegame.png b/examples/particles/images/launcherIcons/samegame.png Binary files differnew file mode 100644 index 0000000000..d00698264b --- /dev/null +++ b/examples/particles/images/launcherIcons/samegame.png diff --git a/examples/particles/images/launcherIcons/shapeanddirection.png b/examples/particles/images/launcherIcons/shapeanddirection.png Binary files differnew file mode 100644 index 0000000000..9c1f910d0c --- /dev/null +++ b/examples/particles/images/launcherIcons/shapeanddirection.png diff --git a/examples/particles/images/launcherIcons/spaceexplorer.png b/examples/particles/images/launcherIcons/spaceexplorer.png Binary files differnew file mode 100644 index 0000000000..770584a0fa --- /dev/null +++ b/examples/particles/images/launcherIcons/spaceexplorer.png diff --git a/examples/particles/images/launcherIcons/spritegoal.png b/examples/particles/images/launcherIcons/spritegoal.png Binary files differnew file mode 100644 index 0000000000..77480c6f09 --- /dev/null +++ b/examples/particles/images/launcherIcons/spritegoal.png diff --git a/examples/particles/images/launcherIcons/sprites.png b/examples/particles/images/launcherIcons/sprites.png Binary files differnew file mode 100644 index 0000000000..144216ac7c --- /dev/null +++ b/examples/particles/images/launcherIcons/sprites.png diff --git a/examples/particles/images/launcherIcons/spritevariedparticles.png b/examples/particles/images/launcherIcons/spritevariedparticles.png Binary files differnew file mode 100644 index 0000000000..495bb6beee --- /dev/null +++ b/examples/particles/images/launcherIcons/spritevariedparticles.png diff --git a/examples/particles/images/launcherIcons/startstop.png b/examples/particles/images/launcherIcons/startstop.png Binary files differnew file mode 100644 index 0000000000..0ff53196a6 --- /dev/null +++ b/examples/particles/images/launcherIcons/startstop.png diff --git a/examples/particles/images/launcherIcons/timedgroupchanges.png b/examples/particles/images/launcherIcons/timedgroupchanges.png Binary files differnew file mode 100644 index 0000000000..ec9f826495 --- /dev/null +++ b/examples/particles/images/launcherIcons/timedgroupchanges.png diff --git a/examples/particles/images/launcherIcons/trailemitter.png b/examples/particles/images/launcherIcons/trailemitter.png Binary files differnew file mode 100644 index 0000000000..39acf8b40d --- /dev/null +++ b/examples/particles/images/launcherIcons/trailemitter.png diff --git a/examples/particles/images/launcherIcons/trails.png b/examples/particles/images/launcherIcons/trails.png Binary files differnew file mode 100644 index 0000000000..0337ebcfd8 --- /dev/null +++ b/examples/particles/images/launcherIcons/trails.png diff --git a/examples/particles/images/launcherIcons/turbulence.png b/examples/particles/images/launcherIcons/turbulence.png Binary files differnew file mode 100644 index 0000000000..2b9446ea90 --- /dev/null +++ b/examples/particles/images/launcherIcons/turbulence.png diff --git a/examples/particles/images/launcherIcons/velocityfrommotion.png b/examples/particles/images/launcherIcons/velocityfrommotion.png Binary files differnew file mode 100644 index 0000000000..79baa08293 --- /dev/null +++ b/examples/particles/images/launcherIcons/velocityfrommotion.png diff --git a/examples/particles/images/launcherIcons/wander.png b/examples/particles/images/launcherIcons/wander.png Binary files differnew file mode 100644 index 0000000000..d98e14b8ae --- /dev/null +++ b/examples/particles/images/launcherIcons/wander.png diff --git a/examples/particles/images/matchmask.png b/examples/particles/images/matchmask.png Binary files differnew file mode 100644 index 0000000000..e575875c55 --- /dev/null +++ b/examples/particles/images/matchmask.png diff --git a/examples/particles/images/meteor.png b/examples/particles/images/meteor.png Binary files differnew file mode 100644 index 0000000000..e8c368aea7 --- /dev/null +++ b/examples/particles/images/meteor.png diff --git a/examples/particles/images/meteor_explo.png b/examples/particles/images/meteor_explo.png Binary files differnew file mode 100644 index 0000000000..e659bfe2cf --- /dev/null +++ b/examples/particles/images/meteor_explo.png diff --git a/examples/particles/images/meteors.png b/examples/particles/images/meteors.png Binary files differnew file mode 100644 index 0000000000..bada8a1407 --- /dev/null +++ b/examples/particles/images/meteors.png diff --git a/examples/particles/images/nullRock.png b/examples/particles/images/nullRock.png Binary files differnew file mode 100644 index 0000000000..4076327a1a --- /dev/null +++ b/examples/particles/images/nullRock.png diff --git a/examples/particles/images/particle.png b/examples/particles/images/particle.png Binary files differnew file mode 100644 index 0000000000..5c83896d22 --- /dev/null +++ b/examples/particles/images/particle.png diff --git a/examples/particles/images/particle2.png b/examples/particles/images/particle2.png Binary files differnew file mode 100644 index 0000000000..36349c6c6e --- /dev/null +++ b/examples/particles/images/particle2.png diff --git a/examples/particles/images/particle3.png b/examples/particles/images/particle3.png Binary files differnew file mode 100644 index 0000000000..905d8f37b8 --- /dev/null +++ b/examples/particles/images/particle3.png diff --git a/examples/particles/images/particle4.png b/examples/particles/images/particle4.png Binary files differnew file mode 100644 index 0000000000..bc95b703c1 --- /dev/null +++ b/examples/particles/images/particle4.png diff --git a/examples/particles/images/particleA.png b/examples/particles/images/particleA.png Binary files differnew file mode 100644 index 0000000000..c63acdee1f --- /dev/null +++ b/examples/particles/images/particleA.png diff --git a/examples/particles/images/portal_bg.png b/examples/particles/images/portal_bg.png Binary files differnew file mode 100644 index 0000000000..3c59eeabb9 --- /dev/null +++ b/examples/particles/images/portal_bg.png diff --git a/examples/particles/images/realLeaf1.png b/examples/particles/images/realLeaf1.png Binary files differnew file mode 100644 index 0000000000..6cabf29efd --- /dev/null +++ b/examples/particles/images/realLeaf1.png diff --git a/examples/particles/images/realLeaf2.png b/examples/particles/images/realLeaf2.png Binary files differnew file mode 100644 index 0000000000..bfeca861d5 --- /dev/null +++ b/examples/particles/images/realLeaf2.png diff --git a/examples/particles/images/realLeaf3.png b/examples/particles/images/realLeaf3.png Binary files differnew file mode 100644 index 0000000000..b1071e862b --- /dev/null +++ b/examples/particles/images/realLeaf3.png diff --git a/examples/particles/images/realLeaf4.png b/examples/particles/images/realLeaf4.png Binary files differnew file mode 100644 index 0000000000..d61d53d10e --- /dev/null +++ b/examples/particles/images/realLeaf4.png diff --git a/examples/particles/images/rocket.png b/examples/particles/images/rocket.png Binary files differnew file mode 100644 index 0000000000..a171610b03 --- /dev/null +++ b/examples/particles/images/rocket.png diff --git a/examples/particles/images/rocket2.png b/examples/particles/images/rocket2.png Binary files differnew file mode 100644 index 0000000000..7110f8fdc6 --- /dev/null +++ b/examples/particles/images/rocket2.png diff --git a/examples/particles/images/sizeInOut.png b/examples/particles/images/sizeInOut.png Binary files differnew file mode 100644 index 0000000000..0a306ea21a --- /dev/null +++ b/examples/particles/images/sizeInOut.png diff --git a/examples/particles/images/snowflake.png b/examples/particles/images/snowflake.png Binary files differnew file mode 100644 index 0000000000..490887a82f --- /dev/null +++ b/examples/particles/images/snowflake.png diff --git a/examples/particles/images/sparkleSize.png b/examples/particles/images/sparkleSize.png Binary files differnew file mode 100644 index 0000000000..752056541b --- /dev/null +++ b/examples/particles/images/sparkleSize.png diff --git a/examples/particles/images/star.png b/examples/particles/images/star.png Binary files differnew file mode 100644 index 0000000000..0d592cfa87 --- /dev/null +++ b/examples/particles/images/star.png diff --git a/examples/particles/images/starfish_0.png b/examples/particles/images/starfish_0.png Binary files differnew file mode 100644 index 0000000000..8747f0236e --- /dev/null +++ b/examples/particles/images/starfish_0.png diff --git a/examples/particles/images/starfish_1.png b/examples/particles/images/starfish_1.png Binary files differnew file mode 100644 index 0000000000..1f3f159d5e --- /dev/null +++ b/examples/particles/images/starfish_1.png diff --git a/examples/particles/images/starfish_2.png b/examples/particles/images/starfish_2.png Binary files differnew file mode 100644 index 0000000000..c6c7e5a676 --- /dev/null +++ b/examples/particles/images/starfish_2.png diff --git a/examples/particles/images/starfish_3.png b/examples/particles/images/starfish_3.png Binary files differnew file mode 100644 index 0000000000..307a89f815 --- /dev/null +++ b/examples/particles/images/starfish_3.png diff --git a/examples/particles/images/starfish_4.png b/examples/particles/images/starfish_4.png Binary files differnew file mode 100644 index 0000000000..d61c26545a --- /dev/null +++ b/examples/particles/images/starfish_4.png diff --git a/examples/particles/images/starfish_mask.png b/examples/particles/images/starfish_mask.png Binary files differnew file mode 100644 index 0000000000..2ef74f902b --- /dev/null +++ b/examples/particles/images/starfish_mask.png diff --git a/examples/particles/itemparticle/content/Delegate.qml b/examples/particles/itemparticle/content/Delegate.qml new file mode 100644 index 0000000000..97c7840cb4 --- /dev/null +++ b/examples/particles/itemparticle/content/Delegate.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 + +//![0] +Package { + Text { id: listDelegate; width: 200; height: 25; text: 'Empty'; Package.name: 'list' } + Text { id: gridDelegate; width: 100; height: 50; text: 'Empty'; Package.name: 'grid' } + + Rectangle { + id: wrapper + width: 200; height: 25 + color: 'lightsteelblue' + + Text { text: display; anchors.centerIn: parent } + MouseArea { + anchors.fill: parent + onClicked: { + if (wrapper.state == 'inList') + wrapper.state = 'inGrid'; + else + wrapper.state = 'inList'; + } + } + + state: 'inList' + states: [ + State { + name: 'inList' + ParentChange { target: wrapper; parent: listDelegate } + }, + State { + name: 'inGrid' + ParentChange { + target: wrapper; parent: gridDelegate + x: 0; y: 0; width: gridDelegate.width; height: gridDelegate.height + } + } + ] + + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } +} +//![0] diff --git a/examples/particles/itemparticle/content/Delegate2.qml b/examples/particles/itemparticle/content/Delegate2.qml new file mode 100644 index 0000000000..cf60d43dc2 --- /dev/null +++ b/examples/particles/itemparticle/content/Delegate2.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 + +//![0] +Package { + Item { id: gridDelegate; width: w; height: h; Package.name: 'grid' } + Item { id: particleDelegate; width: w; height: h; Package.name: 'particles' + + Rectangle { + id: wrapper + width: w; height: h; + color: col + rotation: Math.random()*360 + Behavior on rotation {RotationAnimation {}} + + states: State { + name: "gridded" + when: root.inGrid + PropertyChanges { + target: wrapper + rotation: 0 + } + ParentChange { + target: wrapper + parent: gridDelegate + x:0 + y:0 + } + } + transitions: [ + Transition { + ParentAnimation { + NumberAnimation { properties: 'x,y,width,height'; duration: 300 } + } + } + ] + } + } +} +//![0] diff --git a/examples/particles/itemparticle/content/ExpandingDelegate.qml b/examples/particles/itemparticle/content/ExpandingDelegate.qml new file mode 100644 index 0000000000..87f723d3f7 --- /dev/null +++ b/examples/particles/itemparticle/content/ExpandingDelegate.qml @@ -0,0 +1,204 @@ +/**************************************************************************** +** +** 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 "../../../modelviews/listview/content" + +// This example illustrates expanding a list item to show a more detailed view. + + // Delegate for the recipes. This delegate has two modes: + // 1. List mode (default), which just shows the picture and title of the recipe. + // 2. Details mode, which also shows the ingredients and method. + Component { + id: recipeDelegate + + Item { + id: recipe + + // Create a property to contain the visibility of the details. + // We can bind multiple element's opacity to this one property, + // rather than having a "PropertyChanges" line for each element we + // want to fade. + property real detailsOpacity : 0 + + //this bit changed for aesthetics + width: 70 + height: 70 + // A simple rounded rectangle for the background + Rectangle { + id: background + x: 2; y: 2; width: parent.width - x*2; height: parent.height - y*2 + color: "ivory" + border.color: "orange" + radius: 5 + } + Image { + anchors.fill:parent + anchors.margins: -32 + source: "bubble.png" + } + + + // This mouse region covers the entire delegate. + // When clicked it changes mode to 'Details'. If we are already + // in Details mode, then no change will happen. + MouseArea { + anchors.fill: parent + onClicked: recipe.state = 'Details'; + } + + // Lay out the page: picture, title and ingredients at the top, and method at the + // bottom. Note that elements that should not be visible in the list + // mode have their opacity set to recipe.detailsOpacity. + Row { + id: topLayout + x: 10; y: 10; height: recipeImage.height; width: parent.width + spacing: 10 + + Image { + id: recipeImage + width: 50; height: 50 + source: "../../modelviews/listview/" + picture + } + + Column { + width: background.width - recipeImage.width - 20; height: recipeImage.height + spacing: 5 + + Text { + text: title + font.bold: true; font.pointSize: 16 + } + + Text { + text: "Ingredients" + font.pointSize: 12; font.bold: true + opacity: recipe.detailsOpacity + } + + Text { + text: ingredients + wrapMode: Text.WordWrap + width: parent.width + opacity: recipe.detailsOpacity + } + } + } + + Item { + id: details + x: 10; width: parent.width - 20 + anchors { top: topLayout.bottom; topMargin: 10; bottom: parent.bottom; bottomMargin: 10 } + opacity: recipe.detailsOpacity + + Text { + id: methodTitle + anchors.top: parent.top + text: "Method" + font.pointSize: 12; font.bold: true + } + + Flickable { + id: flick + width: parent.width + anchors { top: methodTitle.bottom; bottom: parent.bottom } + contentHeight: methodText.height + clip: true + + Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } + } + + Image { + anchors { right: flick.right; top: flick.top } + source: "../../modelviews/listview/" + "content/pics/moreUp.png" + opacity: flick.atYBeginning ? 0 : 1 + } + + Image { + anchors { right: flick.right; bottom: flick.bottom } + source: "../../modelviews/listview/" + "content/pics/moreDown.png" + opacity: flick.atYEnd ? 0 : 1 + } + } + + // A button to close the detailed view, i.e. set the state back to default (''). + TextButton { + y: 10 + anchors { right: background.right; rightMargin: 10 } + opacity: recipe.detailsOpacity + text: "Close" + + onClicked: recipe.state = ''; + } + + states: State { + name: "Details" + + PropertyChanges { target: background; color: "white" } + PropertyChanges { target: recipeImage; width: 130; height: 130 } // Make picture bigger + PropertyChanges { target: recipe; detailsOpacity: 1; x: 0; opacity: 1 } // Make details visible + PropertyChanges { target: recipe; height: root.height; width: root.height; x:0; y:0; z:100} // Fill the entire list area with the detailed view + + // Move the list so that this item is at the top. + //PropertyChanges { target: recipe.ListView.view; explicit: true; contentY: recipe.y } + + // Disallow flicking while we're in detailed view + //PropertyChanges { target: recipe.ListView.view; interactive: false } + } + + transitions: Transition { + //The only strictly necessary particle specific lines + to: "Details" + reversible: true + ScriptAction {script: { + if(state == "Details") + mp.freeze(index); + else + mp.unfreeze(index); + } + } + // Make the state changes smooth + ParallelAnimation { + ColorAnimation { property: "color"; duration: 500 } + NumberAnimation { duration: 300; properties: "detailsOpacity,opacity,x,y,height,width" } + } + } + } + } diff --git a/examples/particles/itemparticle/content/RssModel.qml b/examples/particles/itemparticle/content/RssModel.qml new file mode 100644 index 0000000000..46027600b3 --- /dev/null +++ b/examples/particles/itemparticle/content/RssModel.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** 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.XmlListModel 2.0 + +XmlListModel { + property string tags : "" + + function encodeTags(x) { return encodeURIComponent(x.replace(' ',',')); } + + source: "http://api.flickr.com/services/feeds/photos_public.gne?"+(tags ? "tags="+encodeTags(tags)+"&" : "") + query: "/feed/entry" + namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';" + + XmlRole { name: "title"; query: "title/string()" } + XmlRole { name: "content"; query: "content/string()" } + XmlRole { name: "hq"; query: "link[@rel='enclosure']/@href/string()" } +} diff --git a/examples/particles/itemparticle/content/bubble.png b/examples/particles/itemparticle/content/bubble.png Binary files differnew file mode 100644 index 0000000000..c7f479e9e3 --- /dev/null +++ b/examples/particles/itemparticle/content/bubble.png diff --git a/examples/particles/itemparticle/content/script.js b/examples/particles/itemparticle/content/script.js new file mode 100644 index 0000000000..e8ef93a847 --- /dev/null +++ b/examples/particles/itemparticle/content/script.js @@ -0,0 +1,27 @@ +.pragma library + +function getWidth(string) { + return (string.match(/width=\"([0-9]+)\"/))[1] +} + +function getHeight(string) { + return (string.match(/height=\"([0-9]+)\"/))[1] +} + +function getImagePath(string) { + var pattern = /src=\"http:\/\/(\S+)\"/ + return (string.match(pattern))[1] +} + +function calculateScale(width, height, cellSize) { + var widthScale = (cellSize * 1.0) / width + var heightScale = (cellSize * 1.0) / height + var scale = 0 + + if (widthScale <= heightScale) { + scale = widthScale; + } else if (heightScale < widthScale) { + scale = heightScale; + } + return scale; +} diff --git a/examples/particles/itemparticle/delegates.qml b/examples/particles/itemparticle/delegates.qml new file mode 100644 index 0000000000..58734d320a --- /dev/null +++ b/examples/particles/itemparticle/delegates.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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: "black" + + function newPithySaying() { + switch (Math.floor(Math.random()*16)) { + case 0: return "Hello World"; + case 1: return "G'day Mate"; + case 2: return "Code Less"; + case 3: return "Create More"; + case 4: return "Deploy Everywhere"; + case 5: return "Qt Meta-object Language"; + case 6: return "Qt Magic Language"; + case 7: return "Fluid UIs"; + case 8: return "Touchable"; + case 9: return "How's it going?"; + case 10: return "Do you like text?"; + case 11: return "Enjoy!"; + case 12: return "ERROR: Out of pith"; + case 13: return "Punctuation Failure"; + case 14: return "I can go faster"; + case 15: return "I can go slower"; + default: return "OMGWTFBBQ"; + } + } + + ParticleSystem { + anchors.fill: parent + id: syssy + Emitter { + anchors.centerIn: parent + emitRate: 1 + lifeSpan: 4800 + lifeSpanVariation: 1600 + speed: AngleDirection {angleVariation: 360; magnitude: 40; magnitudeVariation: 20} + } + ItemParticle { + delegate: Text { + text: root.newPithySaying(); + color: "white" + font.pixelSize: 18 + font.bold: true + } + } + } +} diff --git a/examples/particles/itemparticle/particleview.qml b/examples/particles/itemparticle/particleview.qml new file mode 100644 index 0000000000..774539a958 --- /dev/null +++ b/examples/particles/itemparticle/particleview.qml @@ -0,0 +1,274 @@ +/**************************************************************************** +** +** 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 +import "content/script.js" as Script +import "content" + +Item { + id: root + width: 640 + height: 480 + Rectangle { + anchors.fill: parent + color: "black" + z: -1 + } + Item { + id: loading + Behavior on opacity {NumberAnimation {}} + anchors.fill: parent + Text { + anchors.centerIn: parent + text: "Loading" + color: "white" + } + } + ParticleSystem { + id: sys; + running: true + } + Emitter { + id: emitter + system: sys + height: parent.height - 132/2 + x: -132/2 + y: 132/2 + speed: PointDirection { x: 32; xVariation: 8 } + emitRate: 0.5 + lifeSpan: Emitter.InfiniteLife + group: "photos" + } + Age { + system: sys + x: parent.width + 132/2 + height: parent.height + width: 1000 + } + ImageParticle { + system: sys + groups: ["fireworks"] + source: "../trails/../images/star.png" + color: "lightsteelblue" + alpha: 0 + colorVariation: 0 + z: 1000 + } + ItemParticle { + id: mp + z: 0 + system: sys + fade: false + groups: ["photos"] + } + Component { + id: alertDelegate + Rectangle { + width: 132 + height: 132 + NumberAnimation on scale { + running: true + loops: 1 + from: 0.2 + to: 1 + } + Image { + source: "../asteroid/../images/rocket.png" + anchors.centerIn: parent + } + Text { + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + text: "A new ship has arrived!" + } + } + } + property Item alertItem; + function alert() { + //resetter.active = false + force.active = true; + alertItem = alertDelegate.createObject(root); + alertItem.x = root.width/2 - alertItem.width/2 + alertItem.y = root.height/2 - alertItem.height/2 + spawnFireworks.pulse(200); + stopAlert.start(); + } + focus: true + Keys.onSpacePressed: alert(); + Timer { + id: stopAlert + running: false + repeat: false + interval: 800 + onTriggered: { + force.active = false + //resetter.active = true; + mp.take(alertItem, true); + centerEmitter.burst(1); + } + } + Attractor { + id: force + system: sys + pointX: root.width/2 + pointY: root.height/2 + strength: -10000 + enabled: false + anchors.centerIn: parent + width: parent.width/2 + height: parent.height/2 + groups:["photos"] + affectedParameter: Attractor.Position + } + Emitter { + id: centerEmitter + speed: PointDirection { x: 32; xVariation: 8;} + emitRate: 0.5 + lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first) + maximumEmitted: 20 + group: "photos" + system: sys + anchors.centerIn: parent + enabled: false + + //TODO: Zoom in effect + } + Emitter { + id: spawnFireworks + group: "fireworks" + system: sys + maximumEmitted: 400 + emitRate: 400 + lifeSpan: 2800 + x: parent.width/2 + y: parent.height/2 - 64 + width: 8 + height: 8 + enabled: false + size: 32 + endSize: 8 + speed: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 } + acceleration: PointDirection { y: 160 } + } + Item { x: -1000; y: -1000 //offscreen + Repeater {//Load them here, add to system on completed + model: theModel + delegate: theDelegate + } + } + RssModel {id: theModel; tags:"particle,particles"} + Component { + id: theDelegate + Rectangle { + id: container + border.width: 2 + property real myRand: Math.random();//'depth' + z: Math.floor(myRand * 100) + scale: (myRand + 1.0)/2; + //TODO: Darken based on 'depth' + width: 132 + height: 132 + //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity); + ItemParticle.onDetached: mp.take(container);//respawns + function manage() + { + if (state == "selected") { + console.log("Taking " + index); + mp.freeze(container); + } else { + console.log("Returning " +index); + mp.unfreeze(container); + } + } + Image { + id: img + anchors.centerIn: parent + smooth: true; source: "http://" + Script.getImagePath(content); cache: true + fillMode: Image.PreserveAspectFit; + width: parent.width-4; height: parent.height-4 + onStatusChanged: if (img.status == Image.Ready) { + loading.opacity = 0; + mp.take(container); + } + } + Text { + anchors.bottom: parent.bottom + width: parent.width + horizontalAlignment: Text.AlignHCenter + elide: Text.ElideRight + text: title + color: "black" + } + MouseArea { + anchors.fill: parent + onClicked: container.state == "selected" ? container.state = "" : container.state = "selected" + } + states: State { + name: "selected" + ParentChange { + target: container + parent: root + x: 0 + y: 0 + } + PropertyChanges { + target: container + width: root.width + height: root.height + z: 101 + opacity: 1 + rotation: 0 + } + } + transitions: Transition { + to: "selected" + reversible: true + SequentialAnimation { + ScriptAction {script: container.manage();} + ParallelAnimation { + ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly + NumberAnimation { properties: "width, height, z, rotation" } + } + } + } + } + } +} diff --git a/examples/particles/particles.pro b/examples/particles/particles.pro new file mode 100644 index 0000000000..967108504e --- /dev/null +++ b/examples/particles/particles.pro @@ -0,0 +1 @@ +TEMPLATE = subdirs diff --git a/examples/particles/simple/dynamiccomparison.qml b/examples/particles/simple/dynamiccomparison.qml new file mode 100644 index 0000000000..a7cdb9b32a --- /dev/null +++ b/examples/particles/simple/dynamiccomparison.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 { + 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 + speed: 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 new file mode 100644 index 0000000000..4431ebe82e --- /dev/null +++ b/examples/particles/simple/dynamicemitters.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** 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 + speed: 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 new file mode 100644 index 0000000000..c1b85caa2d --- /dev/null +++ b/examples/particles/simple/multiplepainters.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 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 + speed: 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 new file mode 100644 index 0000000000..62105b28a0 --- /dev/null +++ b/examples/particles/simple/startstop.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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 + } +} |