Rename speed -> velocity in the particle system
[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         id: ps
58     }
59     MouseArea {
60         anchors.fill: parent
61         onClicked: turb.enabled = !turb.enabled
62     }
63
64     //! [0]
65     Turbulence {
66         id: turb
67         system: ps
68         enabled: true
69         height: (parent.height / 2) - 4
70         width: parent.width
71         x: parent. width / 4
72         anchors.fill: parent
73         strength: 32
74         NumberAnimation on strength{from: 16; to: 64; easing.type: Easing.InOutBounce; duration: 1800; loops: -1}
75     }
76     //! [0]
77
78     ImageParticle {
79         groups: ["smoke"]
80         system: ps
81         source: "../../images/particle.png"
82         color: "#11111111"
83         colorVariation: 0
84     }
85     ImageParticle {
86         groups: ["flame"]
87         system: ps
88         source: "../../images/particle.png"
89         color: "#11ff400f"
90         colorVariation: 0.1
91     }
92     Emitter {
93         anchors.centerIn: parent
94         system: ps
95         group: "flame"
96         
97         emitRate: 120
98         lifeSpan: 1200
99         size: 20
100         endSize: 10
101         sizeVariation: 10
102         acceleration: PointDirection { y: -40 }
103         velocity: AngleDirection { angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
104     }
105     TrailEmitter {
106         id: smoke1
107         width: root.width
108         height: root.height/2
109         system: ps
110         group: "smoke"
111         follow: "flame"
112
113         emitRatePerParticle: 1
114         lifeSpan: 2400
115         lifeSpanVariation: 400
116         size: 16
117         endSize: 8
118         sizeVariation: 8
119         acceleration: PointDirection { y: -40 }
120         velocity: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
121     }
122     TrailEmitter {
123         id: smoke2
124         width: root.width
125         height: root.height/2 - 20
126         system: ps
127         group: "smoke"
128         follow: "flame"
129         
130         emitRatePerParticle: 4
131         lifeSpan: 2400
132         size: 36
133         endSize: 24
134         sizeVariation: 12
135         acceleration: PointDirection { y: -40 }
136         velocity: AngleDirection { angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
137     }
138 }