aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/particles
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/particles')
-rw-r--r--examples/quick/particles/affectors/content/customaffector.qml4
-rw-r--r--examples/quick/particles/affectors/content/groupgoal.qml4
-rw-r--r--examples/quick/particles/emitters/content/burstandpulse.qml8
-rw-r--r--examples/quick/particles/emitters/content/customemitter.qml6
-rw-r--r--examples/quick/particles/imageparticle/content/sharing.qml90
-rw-r--r--examples/quick/particles/itemparticle/particleview.qml13
6 files changed, 67 insertions, 58 deletions
diff --git a/examples/quick/particles/affectors/content/customaffector.qml b/examples/quick/particles/affectors/content/customaffector.qml
index 71646bcf39..6fabfb3ab2 100644
--- a/examples/quick/particles/affectors/content/customaffector.qml
+++ b/examples/quick/particles/affectors/content/customaffector.qml
@@ -81,7 +81,7 @@ Item {
property real velocity: 1.5
width: parent.width
height: parent.height - 100
- onAffectParticles: {
+ onAffectParticles: (particles, dt) => {
/* //Linear movement
if (particle.r == 0) {
particle.r = Math.random() > 0.5 ? -1 : 1;
@@ -117,7 +117,7 @@ Item {
width: parent.width + 120
height: 100
anchors.bottom: parent.bottom
- onAffectParticles: {
+ onAffectParticles: (particles, dt) => {
for (var i=0; i<particles.length; i++) {
var particle = particles[i];
var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
diff --git a/examples/quick/particles/affectors/content/groupgoal.qml b/examples/quick/particles/affectors/content/groupgoal.qml
index 6472a3b450..9910531a98 100644
--- a/examples/quick/particles/affectors/content/groupgoal.qml
+++ b/examples/quick/particles/affectors/content/groupgoal.qml
@@ -62,7 +62,7 @@ Rectangle {
Text {
color: "white"
anchors.right: parent.right
- text: score
+ text: root.score
}
ParticleSystem {
@@ -96,7 +96,7 @@ Rectangle {
ParticleGroup {
name: "lit"
duration: 10000
- onEntered: score++;
+ onEntered: root.score++
TrailEmitter {
id: fireballFlame
group: "flame"
diff --git a/examples/quick/particles/emitters/content/burstandpulse.qml b/examples/quick/particles/emitters/content/burstandpulse.qml
index 8bd19ed8ed..d3c38c2360 100644
--- a/examples/quick/particles/emitters/content/burstandpulse.qml
+++ b/examples/quick/particles/emitters/content/burstandpulse.qml
@@ -52,6 +52,8 @@ import QtQuick 2.0
import QtQuick.Particles 2.0
Rectangle {
+ id: root
+
width: 320
height: 480
color: "black"
@@ -63,12 +65,12 @@ Rectangle {
repeat: true
onTriggered: {
//! [0]
- if (lastWasPulse) {
+ if (root.lastWasPulse) {
burstEmitter.burst(500);
- lastWasPulse = false;
+ root.lastWasPulse = false;
} else {
pulseEmitter.pulse(500);
- lastWasPulse = true;
+ root.lastWasPulse = true;
}
//! [0]
}
diff --git a/examples/quick/particles/emitters/content/customemitter.qml b/examples/quick/particles/emitters/content/customemitter.qml
index aa8ca6b2f9..f6aea13d08 100644
--- a/examples/quick/particles/emitters/content/customemitter.qml
+++ b/examples/quick/particles/emitters/content/customemitter.qml
@@ -79,7 +79,7 @@ ParticleSystem {
size: 12
anchors.centerIn: parent
//! [0]
- onEmitParticles: {
+ onEmitParticles: (particles) => {
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));
@@ -90,8 +90,8 @@ ParticleSystem {
theta /= 6.0;
theta *= 2.0*Math.PI;
theta += sys.convert(sys.petalRotation);//Convert from degrees to radians
- particle.initialVX = petalLength * Math.cos(theta);
- particle.initialVY = petalLength * Math.sin(theta);
+ particle.initialVX = sys.petalLength * Math.cos(theta);
+ particle.initialVY = sys.petalLength * Math.sin(theta);
particle.initialAX = particle.initialVX * -0.5;
particle.initialAY = particle.initialVY * -0.5;
}
diff --git a/examples/quick/particles/imageparticle/content/sharing.qml b/examples/quick/particles/imageparticle/content/sharing.qml
index 1018a8e8ba..13b0dadf85 100644
--- a/examples/quick/particles/imageparticle/content/sharing.qml
+++ b/examples/quick/particles/imageparticle/content/sharing.qml
@@ -56,6 +56,8 @@ import QtQuick 2.0
import QtQuick.Particles 2.0
Rectangle {
+ id: root
+
property real delegateHeight: 65
width: 200; height: 300
gradient: Gradient {
@@ -65,53 +67,53 @@ Rectangle {
// 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 }
- }
- MouseArea { anchors.fill: parent; onClicked: listView.currentIndex = index; }
- // 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 }
- }
+ component PetDelegate: Item {
+ id: pet
+ width: 200; height: root.delegateHeight
+ z: 10
+
+ required property int index
+ required property string name
+ required property string type
+ required property int age
+
+ Column {
+ Text {color: "white"; text: pet.name; font.pixelSize: 18 }
+ Text {color: "white"; text: 'Type: ' + pet.type; font.pixelSize: 14 }
+ Text {color: "white"; text: 'Age: ' + pet.age; font.pixelSize: 14 }
+ }
+ MouseArea { anchors.fill: parent; onClicked: listView.currentIndex = pet.index; }
+ // indent the item if it is the current item
+ states: State {
+ name: "Current"
+ when: pet.ListView.isCurrentItem
+ PropertyChanges { target: pet; x: 20 }
+ }
+ transitions: Transition {
+ NumberAnimation { properties: "x"; duration: 200 }
}
}
// Define a highlight with customized movement between items.
- Component {
- id: highlightBar
- Rectangle {
- z: 0
- width: 200; height: delegateHeight
- gradient: Gradient {
- GradientStop { position: 0.0; color: "#99FF99" }
- GradientStop { position: 1.0; color: "#88FF88" }
- }
- y: listView.currentItem.y;
- Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
- //! [1]
- ImageParticle {
- anchors.fill: parent
- system: particles
- source: "../../images/flower.png"
- color: "red"
- clip: true
- alpha: 1.0
- }
- //! [1]
+ component HighlightBar : Rectangle {
+ z: 0
+ width: 200; height: root.delegateHeight
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#99FF99" }
+ GradientStop { position: 1.0; color: "#88FF88" }
+ }
+ y: listView.currentItem.y;
+ Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } }
+ //! [1]
+ ImageParticle {
+ anchors.fill: parent
+ system: particles
+ source: "../../images/flower.png"
+ color: "red"
+ clip: true
+ alpha: 1.0
}
+ //! [1]
}
ListView {
@@ -119,12 +121,12 @@ Rectangle {
width: 200; height: parent.height
model: petsModel
- delegate: petDelegate
+ 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
+ highlight: HighlightBar {}
highlightFollowsCurrentItem: false
ParticleSystem { id: particles }
diff --git a/examples/quick/particles/itemparticle/particleview.qml b/examples/quick/particles/itemparticle/particleview.qml
index 3b412e37e5..8eb18dc283 100644
--- a/examples/quick/particles/itemparticle/particleview.qml
+++ b/examples/quick/particles/itemparticle/particleview.qml
@@ -156,7 +156,7 @@ Item {
interval: 800
onTriggered: {
force.enabled = false;
- mp.take(alertItem, true);
+ mp.take(root.alertItem, true);
centerEmitter.burst(1);
}
}
@@ -216,6 +216,11 @@ Item {
Component {
id: theDelegate
Image {
+ required property int index
+ required property string title
+ required property string media
+ required property string thumbnail
+
id: image
antialiasing: true;
source: thumbnail
@@ -237,7 +242,7 @@ Item {
width: parent.paintedWidth + 1
height: parent.paintedHeight + 1
color: "black"
- opacity: darken * (1 - depth)
+ opacity: image.darken * (1 - image.depth)
antialiasing: true;
}
Text {
@@ -247,7 +252,7 @@ Item {
width: parent.paintedWidth - 4
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
- text: title
+ text: image.title
color: "black"
}
ItemParticle.onDetached: mp.take(image); // respawns
@@ -277,7 +282,7 @@ Item {
}
PropertyChanges {
target: image
- source: media
+ source: image.media
x: 0
y: 0
width: root.width