Particle example restyling
[profile/ivi/qtdeclarative.git] / examples / particles / affectors / content / turbulence.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the examples of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 **   * Redistributions of source code must retain the above copyright
15 **     notice, this list of conditions and the following disclaimer.
16 **   * Redistributions in binary form must reproduce the above copyright
17 **     notice, this list of conditions and the following disclaimer in
18 **     the documentation and/or other materials provided with the
19 **     distribution.
20 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 **     the names of its contributors may be used to endorse or promote
22 **     products derived from this software without specific prior written
23 **     permission.
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 import QtQuick 2.0
42 import QtQuick.Particles 2.0
43
44 Rectangle {
45     width: 320
46     height: 480
47     color: "#222222"
48     id: root
49     Image {
50         source: "../../images/candle.png"
51         anchors.bottom: parent.bottom
52         anchors.horizontalCenter: parent.horizontalCenter
53         anchors.bottomMargin: -60
54         anchors.horizontalCenterOffset: 2
55     }
56     ParticleSystem {
57         anchors.fill: parent
58         MouseArea {
59             anchors.fill: parent
60             onClicked: turb.enabled = !turb.enabled
61         }
62
63         //! [0]
64         Turbulence {
65             id: turb
66             enabled: true
67             height: (parent.height / 2) - 4
68             width: parent.width
69             x: parent. width / 4
70             anchors.fill: parent
71             strength: 32
72             NumberAnimation on strength{from: 16; to: 64; easing.type: Easing.InOutBounce; duration: 1800; loops: -1}
73         }
74         //! [0]
75
76         ImageParticle {
77             groups: ["smoke"]
78             source: "../../images/particle.png"
79             color: "#11111111"
80             colorVariation: 0
81         }
82         ImageParticle {
83             groups: ["flame"]
84             source: "../../images/particle.png"
85             color: "#11ff400f"
86             colorVariation: 0.1
87         }
88         Emitter {
89             anchors.centerIn: parent
90             group: "flame"
91
92             emitRate: 120
93             lifeSpan: 1200
94             size: 20
95             endSize: 10
96             sizeVariation: 10
97             acceleration: PointDirection { y: -40 }
98             velocity: AngleDirection { angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
99         }
100         TrailEmitter {
101             id: smoke1
102             width: root.width
103             height: root.height/2
104             group: "smoke"
105             follow: "flame"
106
107             emitRatePerParticle: 1
108             lifeSpan: 2400
109             lifeSpanVariation: 400
110             size: 16
111             endSize: 8
112             sizeVariation: 8
113             acceleration: PointDirection { y: -40 }
114             velocity: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
115         }
116         TrailEmitter {
117             id: smoke2
118             width: root.width
119             height: root.height/2 - 20
120             group: "smoke"
121             follow: "flame"
122
123             emitRatePerParticle: 4
124             lifeSpan: 2400
125             size: 36
126             endSize: 24
127             sizeVariation: 12
128             acceleration: PointDirection { y: -40 }
129             velocity: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
130         }
131     }
132 }