diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-06-08 13:19:56 +1000 |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2011-06-08 13:28:21 +1000 |
commit | 1f88f2ceedf00f96e2491ecdd1c655b0f12f3632 (patch) | |
tree | 1900da1a3793da99f9601762d337cf82dc4701ce /examples | |
parent | 984f21f18d1a3981e7363df467ff2e24e69aa847 (diff) |
Immense Particles Refactor Part C
Demos work again (also, the examples I missed).
Added an example launcher for particles.
Diffstat (limited to 'examples')
37 files changed, 276 insertions, 4 deletions
diff --git a/examples/declarative/particles/asteroid/blackhole.qml b/examples/declarative/particles/asteroid/blackhole.qml index f2c9d0a98d..1bc406b00c 100644 --- a/examples/declarative/particles/asteroid/blackhole.qml +++ b/examples/declarative/particles/asteroid/blackhole.qml @@ -98,6 +98,7 @@ Rectangle{ image: "content/star.png" color: "white" colorVariation: 0.1 + alpha: 0 } ImageParticle{ id: roids @@ -144,9 +145,11 @@ Rectangle{ colorVariation: 0.2 } - GravitationalSingularity{ + PointAttractor{ id: gs; x: root.width/2; y: root.height/2; strength: 4000000; system: particles + physics: PointAttractor.Acceleration + proportionalToDistance: PointAttractor.Quadratic } Kill{ system: particles diff --git a/examples/declarative/particles/exampleslauncher.qml b/examples/declarative/particles/exampleslauncher.qml new file mode 100644 index 0000000000..c08123cf44 --- /dev/null +++ b/examples/declarative/particles/exampleslauncher.qml @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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 "launcherContent/launcher.js" as Util +import "launcherContent" + +Rectangle{ + color: "black" + width: 360 + height: 600 + Shell{ + z: 1 + id: shell + anchors.fill: parent + } + property string emissionMode: "Falling" + onEmissionModeChanged: workaround.active = true + VisualDataModel{//TODO: Transitions between modes + id: vdm + model: [ + "../spaceexplorer/spaceexplorer.qml", + "../snow/snow.qml", + "../asteroid/asteroid.qml", + "../asteroid/blackhole.qml", + "../custom/blurparticles.qml", + "../modelparticles/bubbles.qml", + "../modelparticles/gridsplosion.qml", + "../modelparticles/package.qml", + "../modelparticles/stream.qml", + "../allsmiles/plain.qml", + "../allsmiles/smile.qml", + "../allsmiles/smilefactory.qml", + "../allsmiles/ultraparticles.qml", + "../allsmiles/spriteparticles.qml", + "../allsmiles/spritestateparticles.qml", + "../allsmiles/spritevariedparticles.qml", + "../trails/velocityfrommotion.qml", + "../trails/fireballs.qml", + "../trails/list.qml", + "../trails/portal.qml", + "../trails/rainbow.qml", + "../trails/dynamicemitters.qml", + "../trails/overburst.qml", + "../trails/layered.qml", + "../trails/shimmer.qml", + "../trails/turbulence.qml", + "../../../../demos/declarative/samegame/samegame.qml", + "../../../../demos/declarative/plasmapatrol/plasmapatrol.qml", + "../../../../demos/declarative/flickr/flickr.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 + anchors.bottomMargin: 128 + model: vdm + visible: emissionMode == "Grid" + opacity: visible?1:0 + Behavior on opacity{NumberAnimation{}} + } + ParticleSystem{ id: sys } + ModelParticle{ + system: sys + model: vdm + } + Kill{ + //TODO: File bug? + id: workaround + system: sys + active: false + onActiveChanged: timer.start() + Timer{ + id: timer + interval: 32 + running: false + repeat: false + onTriggered: workaround.active = false + } + } + Emitter{ + system: sys + emitting: emissionMode == "Falling" + width: parent.width + particlesPerSecond: 2 + particleDuration: 6000 + speed: PointDirection{y:100;} + } + Emitter{ + system: sys + emitting: emissionMode == "Bursting" + anchors.centerIn: parent + particlesPerSecond: 2 + particleDuration: 6000 + speed: AngledDirection{magnitude: 60; angleVariation: 360} + } + Emitter{ + system: sys + emitting: emissionMode == "Shimmering" + anchors.fill: parent + particlesPerSecond: 4 + particleDuration: 4000 + } + Row{ + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + Button{ + text:"Grid" + onClicked: emissionMode = "Grid"; + } + Button{ + text:"Fall" + onClicked: emissionMode = "Falling"; + } + Button{ + text:"Burst" + onClicked: emissionMode = "Bursting"; + } + Button{ + text:"Shimmer" + onClicked: emissionMode = "Shimmering"; + } + } +} diff --git a/examples/declarative/particles/snow/content/Button.qml b/examples/declarative/particles/launcherContent/Button.qml index a937b3bede..a937b3bede 100644 --- a/examples/declarative/particles/snow/content/Button.qml +++ b/examples/declarative/particles/launcherContent/Button.qml diff --git a/examples/declarative/particles/launcherContent/Shell.qml b/examples/declarative/particles/launcherContent/Shell.qml new file mode 100644 index 0000000000..32b0cd624c --- /dev/null +++ b/examples/declarative/particles/launcherContent/Shell.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** 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: "icons/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/declarative/particles/launcherContent/icons/asteroid.png b/examples/declarative/particles/launcherContent/icons/asteroid.png Binary files differnew file mode 100644 index 0000000000..77480c6f09 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/asteroid.png diff --git a/examples/declarative/particles/launcherContent/icons/blackhole.png b/examples/declarative/particles/launcherContent/icons/blackhole.png Binary files differnew file mode 100644 index 0000000000..4bd8040c3b --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/blackhole.png diff --git a/examples/declarative/particles/launcherContent/icons/blurparticles.png b/examples/declarative/particles/launcherContent/icons/blurparticles.png Binary files differnew file mode 100644 index 0000000000..7a247ae46e --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/blurparticles.png diff --git a/examples/declarative/particles/launcherContent/icons/close.png b/examples/declarative/particles/launcherContent/icons/close.png Binary files differnew file mode 100644 index 0000000000..c37714ee8f --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/close.png diff --git a/examples/declarative/particles/launcherContent/icons/dynamicemitters.png b/examples/declarative/particles/launcherContent/icons/dynamicemitters.png Binary files differnew file mode 100644 index 0000000000..0cdef9d21e --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/dynamicemitters.png diff --git a/examples/declarative/particles/launcherContent/icons/fireballs.png b/examples/declarative/particles/launcherContent/icons/fireballs.png Binary files differnew file mode 100644 index 0000000000..39acf8b40d --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/fireballs.png diff --git a/examples/declarative/particles/launcherContent/icons/flickr.png b/examples/declarative/particles/launcherContent/icons/flickr.png Binary files differnew file mode 100644 index 0000000000..4de2650280 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/flickr.png diff --git a/examples/declarative/particles/launcherContent/icons/gridsplosion.png b/examples/declarative/particles/launcherContent/icons/gridsplosion.png Binary files differnew file mode 100644 index 0000000000..ec75453df6 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/gridsplosion.png diff --git a/examples/declarative/particles/launcherContent/icons/layered.png b/examples/declarative/particles/launcherContent/icons/layered.png Binary files differnew file mode 100644 index 0000000000..a28e3c4f02 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/layered.png diff --git a/examples/declarative/particles/launcherContent/icons/list.png b/examples/declarative/particles/launcherContent/icons/list.png Binary files differnew file mode 100644 index 0000000000..bc13263cff --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/list.png diff --git a/examples/declarative/particles/launcherContent/icons/overburst.png b/examples/declarative/particles/launcherContent/icons/overburst.png Binary files differnew file mode 100644 index 0000000000..4ef0435991 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/overburst.png diff --git a/examples/declarative/particles/launcherContent/icons/package.png b/examples/declarative/particles/launcherContent/icons/package.png Binary files differnew file mode 100644 index 0000000000..eba8951c26 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/package.png diff --git a/examples/declarative/particles/launcherContent/icons/plain.png b/examples/declarative/particles/launcherContent/icons/plain.png Binary files differnew file mode 100644 index 0000000000..dd51498514 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/plain.png diff --git a/examples/declarative/particles/launcherContent/icons/plasmapatrol.png b/examples/declarative/particles/launcherContent/icons/plasmapatrol.png Binary files differnew file mode 100644 index 0000000000..fda852b420 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/plasmapatrol.png diff --git a/examples/declarative/particles/launcherContent/icons/portal.png b/examples/declarative/particles/launcherContent/icons/portal.png Binary files differnew file mode 100644 index 0000000000..9c1f910d0c --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/portal.png diff --git a/examples/declarative/particles/launcherContent/icons/rainbow.png b/examples/declarative/particles/launcherContent/icons/rainbow.png Binary files differnew file mode 100644 index 0000000000..8841ea30f9 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/rainbow.png diff --git a/examples/declarative/particles/launcherContent/icons/remove.png b/examples/declarative/particles/launcherContent/icons/remove.png Binary files differnew file mode 100644 index 0000000000..c37714ee8f --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/remove.png diff --git a/examples/declarative/particles/launcherContent/icons/samegame.png b/examples/declarative/particles/launcherContent/icons/samegame.png Binary files differnew file mode 100644 index 0000000000..d00698264b --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/samegame.png diff --git a/examples/declarative/particles/launcherContent/icons/shimmer.png b/examples/declarative/particles/launcherContent/icons/shimmer.png Binary files differnew file mode 100644 index 0000000000..0ff53196a6 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/shimmer.png diff --git a/examples/declarative/particles/launcherContent/icons/smile.png b/examples/declarative/particles/launcherContent/icons/smile.png Binary files differnew file mode 100644 index 0000000000..f990e6c03e --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/smile.png diff --git a/examples/declarative/particles/launcherContent/icons/smilefactory.png b/examples/declarative/particles/launcherContent/icons/smilefactory.png Binary files differnew file mode 100644 index 0000000000..78ea52790f --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/smilefactory.png diff --git a/examples/declarative/particles/launcherContent/icons/snow.png b/examples/declarative/particles/launcherContent/icons/snow.png Binary files differnew file mode 100644 index 0000000000..d98e14b8ae --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/snow.png diff --git a/examples/declarative/particles/launcherContent/icons/spaceexplorer.png b/examples/declarative/particles/launcherContent/icons/spaceexplorer.png Binary files differnew file mode 100644 index 0000000000..770584a0fa --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/spaceexplorer.png diff --git a/examples/declarative/particles/launcherContent/icons/spriteparticles.png b/examples/declarative/particles/launcherContent/icons/spriteparticles.png Binary files differnew file mode 100644 index 0000000000..5603964939 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/spriteparticles.png diff --git a/examples/declarative/particles/launcherContent/icons/spritestateparticles.png b/examples/declarative/particles/launcherContent/icons/spritestateparticles.png Binary files differnew file mode 100644 index 0000000000..dd01518ac4 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/spritestateparticles.png diff --git a/examples/declarative/particles/launcherContent/icons/spritevariedparticles.png b/examples/declarative/particles/launcherContent/icons/spritevariedparticles.png Binary files differnew file mode 100644 index 0000000000..495bb6beee --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/spritevariedparticles.png diff --git a/examples/declarative/particles/launcherContent/icons/stream.png b/examples/declarative/particles/launcherContent/icons/stream.png Binary files differnew file mode 100644 index 0000000000..a74f9a0340 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/stream.png diff --git a/examples/declarative/particles/launcherContent/icons/trails.png b/examples/declarative/particles/launcherContent/icons/trails.png Binary files differnew file mode 100644 index 0000000000..0337ebcfd8 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/trails.png diff --git a/examples/declarative/particles/launcherContent/icons/turbulence.png b/examples/declarative/particles/launcherContent/icons/turbulence.png Binary files differnew file mode 100644 index 0000000000..2b9446ea90 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/turbulence.png diff --git a/examples/declarative/particles/launcherContent/icons/ultraparticles.png b/examples/declarative/particles/launcherContent/icons/ultraparticles.png Binary files differnew file mode 100644 index 0000000000..0d87eea427 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/ultraparticles.png diff --git a/examples/declarative/particles/launcherContent/icons/velocityfrommotion.png b/examples/declarative/particles/launcherContent/icons/velocityfrommotion.png Binary files differnew file mode 100644 index 0000000000..79baa08293 --- /dev/null +++ b/examples/declarative/particles/launcherContent/icons/velocityfrommotion.png diff --git a/examples/declarative/particles/launcherContent/launcher.js b/examples/declarative/particles/launcherContent/launcher.js new file mode 100644 index 0000000000..e4fedd30d7 --- /dev/null +++ b/examples/declarative/particles/launcherContent/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 "launcherContent/icons/" + ret[ret.length-1].split('.')[0] + ".png"; +} diff --git a/examples/declarative/particles/snow/snow.qml b/examples/declarative/particles/snow/snow.qml index 2be2438f1d..41adccf7d7 100644 --- a/examples/declarative/particles/snow/snow.qml +++ b/examples/declarative/particles/snow/snow.qml @@ -41,6 +41,7 @@ import QtQuick 2.0 import QtQuick.Particles 2.0 import "content" +import "../launcherContent" as UI Rectangle{ width: 360 @@ -77,15 +78,15 @@ Rectangle{ Row{ anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter - Button{ + UI.Button{ text:"dx/dt" onClicked: wanderer.physics = Wander.Position; } - Button{ + UI.Button{ text:"dv/dt" onClicked: wanderer.physics = Wander.Velocity; } - Button{ + UI.Button{ text:"da/dt" onClicked: wanderer.physics = Wander.Acceleration; } |