blob: 5526988f363ca48912a9e0be3dec34f3a974c1c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import QtQuick 2.0
Item {
id: cloudRoot
x: app.width
y: randomY+deltaY
width: app.width*0.2
height: width*0.4
property int duration: 20000
property string sourceImage: ""
property real deltaY: 0
property real randomY: app.height*0.3
property real amplitudeY: app.height*0.2
function start() {
recalculate()
cloudXAnimation.restart();
cloudYAnimation.restart();
}
function recalculate() {
cloudRoot.duration = Math.random()*15000 + 10000
cloudRoot.x = app.width
cloudRoot.randomY = Math.random()*app.height
cloudRoot.width = app.width*0.2
cloudRoot.height = cloudRoot.width*0.4
cloudRoot.scale = Math.random()*0.6 + 0.7
}
Image {
id: cloud
anchors.fill: cloudRoot
source: cloudRoot.sourceImage
}
SequentialAnimation{
id: cloudYAnimation
NumberAnimation { target: cloudRoot; property: "deltaY"; duration: cloudRoot.duration*0.3; from: 0; to:cloudRoot.amplitudeY; easing.type: Easing.InOutQuad }
NumberAnimation { target: cloudRoot; property: "deltaY"; duration: cloudRoot.duration*0.3; from: cloudRoot.amplitudeY; to:0; easing.type: Easing.InOutQuad }
running: true
onRunningChanged: {
if (!running) {
cloudRoot.amplitudeY = Math.random() * (app.height*0.2)
restart()
}
}
}
NumberAnimation {
id: cloudXAnimation
target: cloudRoot
property: "x"
duration: cloudRoot.duration
to:-cloudRoot.width
running: true
onRunningChanged: {
if (!running) {
recalculate()
restart()
}
}
}
}
|