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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Particles
Item {
id: window
width: 320; height: 480
// Let's draw the sky...
Rectangle {
anchors { left: parent.left; top: parent.top; right: parent.right; bottom: parent.verticalCenter }
//! [0]
gradient: Gradient {
GradientStop {
position: 0.0
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "#14148c"; to: "#0E1533"; duration: 5000 }
ColorAnimation { from: "#0E1533"; to: "#14148c"; duration: 5000 }
}
}
GradientStop {
position: 1.0
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "#14aaff"; to: "#437284"; duration: 5000 }
ColorAnimation { from: "#437284"; to: "#14aaff"; duration: 5000 }
}
}
}
//! [0]
}
// the sun, moon, and stars
Item {
width: parent.width; height: 2 * parent.height
NumberAnimation on rotation { from: 0; to: 360; duration: 10000; loops: Animation.Infinite }
Image {
source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter
rotation: -3 * parent.rotation
}
Image {
source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter
rotation: -parent.rotation
}
ParticleSystem {
id: particlesystem
x: 0; y: parent.height/2
width: parent.width; height: parent.height/2
ImageParticle {
source: "images/star.png"
groups: ["star"]
color: "#00333333"
SequentialAnimation on opacity {
loops: Animation.Infinite
NumberAnimation { from: 0; to: 1; duration: 5000 }
NumberAnimation { from: 1; to: 0; duration: 5000 }
}
}
Emitter {
group: "star"
anchors.fill: parent
emitRate: parent.width / 50
lifeSpan: 5000
}
}
}
// ...and the ground.
Rectangle {
anchors { left: parent.left; top: parent.verticalCenter; right: parent.right; bottom: parent.bottom }
gradient: Gradient {
GradientStop {
position: 0.0
SequentialAnimation on color {
loops: Animation.Infinite
ColorAnimation { from: "#80c342"; to: "#001600"; duration: 5000 }
ColorAnimation { from: "#001600"; to: "#80c342"; duration: 5000 }
}
}
GradientStop { position: 1.0; color: "#006325" }
}
}
}
|