Warning, /plasma/libplasma/examples/wallpapers/autumn/contents/ui/main.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2013 Digia Plc and /or its subsidiary(-ies) <http://www.qt-project.org/legal>
0003
0004 This file is part of the examples of the Qt Toolkit.
0005
0006 SPDX-License-Identifier: BSD-3-Clause
0007 */
0008
0009 import QtQuick
0010 import QtQuick.Particles
0011
0012 Item {
0013 width: 360
0014 height: 600
0015
0016 Image {
0017 source: "../images/backgroundLeaves.jpg"
0018 anchors.fill: parent
0019 }
0020 ParticleSystem {
0021 anchors.fill: parent
0022 Emitter {
0023 width: parent.width
0024 emitRate: 4
0025 lifeSpan: 14000
0026 size: 80
0027 velocity: PointDirection { y: wallpaper.configuration.Speed }
0028 }
0029 Wander {
0030 anchors.fill: parent
0031 anchors.bottomMargin: 100
0032 xVariance: 60
0033 pace: 60
0034 }
0035
0036 //! [0]
0037 Affector {
0038 property real coefficient: 2.0
0039 property real velocity: 1.5
0040 width: parent.width
0041 height: parent.height - 100
0042 onAffectParticles: {
0043 /* //Linear movement
0044 if (particle.r == 0) {
0045 particle.r = Math.random() > 0.5 ? -1 : 1;
0046 } else if (particle.r == 1) {
0047 particle.rotation += velocity * dt;
0048 if (particle.rotation >= maxAngle)
0049 particle.r = -1;
0050 } else if (particle.r == -1) {
0051 particle.rotation -= velocity * dt;
0052 if (particle.rotation <= -1 * maxAngle)
0053 particle.r = 1;
0054 }
0055 */
0056 //Wobbly movement
0057 for (var i=0; i<particles.length; i++) {
0058 var particle = particles[i];
0059 if (particle.r == 0.0) {
0060 particle.r = Math.random() + 0.01;
0061 }
0062 particle.rotation += velocity * particle.r * dt;
0063 particle.r -= particle.rotation * coefficient;
0064 if (particle.r == 0.0)
0065 particle.r -= particle.rotation * 0.000001;
0066 particle.update = 1;
0067 }
0068 }
0069 }
0070 //! [0]
0071
0072 //! [1]
0073 Affector {//Custom Friction, adds some 'randomness'
0074 x: -60
0075 width: parent.width + 120
0076 height: 100
0077 anchors.bottom: parent.bottom
0078 onAffectParticles: {
0079 for (var i=0; i<particles.length; i++) {
0080 var particle = particles[i];
0081 var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1;
0082 var yslow = dt * pseudoRand * 0.5 + 1;
0083 var xslow = dt * pseudoRand * 0.05 + 1;
0084 if (particle.vy < 1)
0085 particle.vy = 0;
0086 else
0087 particle.vy = (particle.vy / yslow);
0088 if (particle.vx < 1)
0089 particle.vx = 0;
0090 else
0091 particle.vx = (particle.vx / xslow);
0092 particle.update = true;
0093 }
0094 }
0095 }
0096 //! [1]
0097
0098 ImageParticle {
0099 anchors.fill: parent
0100 id: particles
0101 sprites: [Sprite {
0102 source: "../images/realLeaf1.png"
0103 frameCount: 1
0104 frameDuration: 1
0105 to: {"a":1, "b":1, "c":1, "d":1}
0106 }, Sprite {
0107 name: "a"
0108 source: "../images/realLeaf1.png"
0109 frameCount: 1
0110 frameDuration: 10000
0111 },
0112 Sprite {
0113 name: "b"
0114 source: "../images/realLeaf2.png"
0115 frameCount: 1
0116 frameDuration: 10000
0117 },
0118 Sprite {
0119 name: "c"
0120 source: "../images/realLeaf3.png"
0121 frameCount: 1
0122 frameDuration: 10000
0123 },
0124 Sprite {
0125 name: "d"
0126 source: "../images/realLeaf4.png"
0127 frameCount: 1
0128 frameDuration: 10000
0129 }
0130 ]
0131
0132 z:4
0133 }
0134 }
0135 }