import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.14
import QtQuick.Particles 2.14
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
color: "grey"
MouseArea {
id: mouse
anchors.fill: parent
hoverEnabled: true
}
ParticleSystem {
id: particlesystem
}
// Emitter发射器
Emitter {
id: emitter
anchors.fill: parent
width: 300
height: 300
system: particlesystem
emitRate: 10 // 发射粒子的速度 一次闪10个
lifeSpan: 600 //生命周期
lifeSpanVariation: 400 // 创建离子的间隔
size: 15
// velocity: PointDirection{ // 控制了粒子移动的方向 如何移动
// x: -45
// xVariation: 0
// yVariation: 100 / 6
// }
}
ImageParticle {
id: img
source: "qrc:/Luffy.png"
system: particlesystem
color: Qt.rgba(153/255,127/255,234/255,1.0)
colorVariation: 1 // 根据color随机修改
}
// Attractor
Attractor {
anchors.fill: parent
enabled: true
system: particlesystem
pointX: mouse.mouseX
pointY: mouse.mouseY
strength: -10000
affectedParameter: Attractor.Acceleration
proportionalToDistance: Attractor.InverseQuadratic
}
// 动画效果Glow
// Text {
// id: txt
// text: qsTr("Waitting")
// font.pixelSize: 70
// anchors.centerIn: parent
// }
// Glow {
// id: glow
// anchors.fill: txt
// radius: 10 // 微光效果程度
// samples: 17
// color: "white"
// source: txt
// SequentialAnimation { // 队列的动画效果
// running: true
// loops: Animation.Infinite // 持续播放动画效果
// NumberAnimation {
// target: glow
// property: "spread"
// to: 0
// duration: 1000
// }
// NumberAnimation {
// target: glow
// property: "spread"
// to: 0.5
// duration: 1000
// }
// }
// }
}
Qt_Note24_QML_Glow&Emitter&Attractor
于 2024-04-16 15:11:09 首次发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)