matrixion/resources/qml/ui/TimelineEffects.qml

141 lines
3.5 KiB
QML
Raw Normal View History

2023-03-24 16:36:42 +03:00
// SPDX-FileCopyrightText: Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick 2.15
import QtQuick.Particles 2.15
Item {
2023-06-19 02:54:32 +03:00
id: effectRoot
2023-10-31 05:11:03 +03:00
2023-03-24 16:36:42 +03:00
readonly property int maxLifespan: Math.max(confettiEmitter.lifeSpan, rainfallEmitter.lifeSpan)
2023-06-19 02:54:32 +03:00
required property bool shouldEffectsRun
2023-03-24 16:36:42 +03:00
2023-10-31 05:11:03 +03:00
function pulseConfetti() {
confettiEmitter.pulse(effectRoot.height * 2);
2023-03-24 16:36:42 +03:00
}
2023-10-31 05:11:03 +03:00
function pulseRainfall() {
rainfallEmitter.pulse(effectRoot.height * 3.3);
2023-03-24 16:36:42 +03:00
}
2023-10-31 05:11:03 +03:00
function removeParticles() {
particleSystem.reset();
}
2023-10-31 05:11:03 +03:00
visible: effectRoot.shouldEffectsRun
2023-03-24 16:36:42 +03:00
ParticleSystem {
id: particleSystem
2023-06-19 02:54:32 +03:00
paused: !effectRoot.shouldEffectsRun
running: effectRoot.shouldEffectsRun
2023-03-24 16:36:42 +03:00
2023-10-31 05:11:03 +03:00
Component.onCompleted: stop()
}
2023-03-24 16:36:42 +03:00
Emitter {
id: confettiEmitter
2023-06-19 02:54:32 +03:00
anchors.horizontalCenter: effectRoot.horizontalCenter
emitRate: Math.min(400 * Math.sqrt(effectRoot.width * effectRoot.height) / 870, 1000)
2023-10-31 05:11:03 +03:00
enabled: false
group: "confetti"
2023-03-24 16:36:42 +03:00
lifeSpan: 15000
maximumEmitted: 500
size: 16
sizeVariation: 4
2023-10-31 05:11:03 +03:00
system: particleSystem
velocityFromMovement: 8
width: effectRoot.width * 3 / 4
y: effectRoot.height
2023-03-24 16:36:42 +03:00
velocity: PointDirection {
x: 0
2023-06-19 02:54:32 +03:00
xVariation: Math.min(4 * effectRoot.width / 7, 450)
2023-10-31 05:11:03 +03:00
y: -Math.min(450 * effectRoot.height / 700, 1000)
2023-03-24 16:36:42 +03:00
yVariation: 250
}
}
ImageParticle {
2023-10-31 05:11:03 +03:00
color: "white"
colorVariation: 1
entryEffect: ImageParticle.None
2023-03-24 16:36:42 +03:00
groups: ["confetti"]
rotationVelocity: 0
rotationVelocityVariation: 360
2023-10-31 05:11:03 +03:00
source: "qrc:/confettiparticle.svg"
system: particleSystem
2023-03-24 16:36:42 +03:00
xVector: PointDirection {
x: 1
xVariation: 0.2
2023-10-31 05:11:03 +03:00
y: 0
2023-03-24 16:36:42 +03:00
yVariation: 0.2
}
yVector: PointDirection {
x: 0
xVariation: 0.2
2023-10-31 05:11:03 +03:00
y: 0.5
2023-03-24 16:36:42 +03:00
yVariation: 0.2
}
}
Gravity {
2023-06-19 02:54:32 +03:00
anchors.fill: effectRoot
2023-03-24 16:36:42 +03:00
angle: 90
2023-10-31 05:11:03 +03:00
groups: ["confetti"]
magnitude: 350
system: particleSystem
2023-03-24 16:36:42 +03:00
}
Emitter {
id: rainfallEmitter
2023-06-19 02:54:32 +03:00
anchors.horizontalCenter: effectRoot.horizontalCenter
emitRate: effectRoot.width / 30
2023-10-31 05:11:03 +03:00
enabled: false
group: "rain"
2023-03-24 16:36:42 +03:00
lifeSpan: 10000
system: particleSystem
2023-10-31 05:11:03 +03:00
width: effectRoot.width
y: -60
2023-03-24 16:36:42 +03:00
velocity: PointDirection {
x: 0
xVariation: 0
2023-10-31 05:11:03 +03:00
y: 400
2023-03-24 16:36:42 +03:00
yVariation: 75
}
// causes high CPU load, see: https://bugreports.qt.io/browse/QTBUG-117923
//ItemParticle {
2023-10-31 05:11:03 +03:00
// system: particleSystem
// groups: ["rain"]
// fade: false
// visible: effectRoot.shouldEffectsRun
// delegate: Rectangle {
// width: 2
// height: 30 + 30 * Math.random()
// radius: 2
// color: "#0099ff"
// }
//}
ImageParticle {
color: "#0099ff"
colorVariation: 0
entryEffect: ImageParticle.None
groups: ["rain"]
rotationVelocity: 0
rotationVelocityVariation: 0
source: "qrc:/confettiparticle.svg"
system: particleSystem
xVector: PointDirection {
x: 0.01
y: 0
}
yVector: PointDirection {
x: 0
y: 5
2023-03-24 16:36:42 +03:00
}
}
}
2023-10-31 05:11:03 +03:00
}