qml闪光特效

文章介绍了如何使用QtQuick库中的QML编写一个在窗口中心以闪光方式逐渐扩大的圆形效果,通过Rectangle和ShapePath创建渐变圆环,并配合PropertyAnimation实现动画。
摘要由CSDN通过智能技术生成

使用qml编写在窗口中心闪光逐渐扩大的特效

import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Shapes 1.7

Window {
    id:root
    visible: true
    width: 400
    height: 400
    title: qsTr("Growing Circle")
    Rectangle{
        id: glowRect
        anchors.centerIn: parent
        width: 0
        height: width

        Shape {
            id:glowCircle
            anchors.fill: parent
            ShapePath {
                fillGradient: RadialGradient {
                    centerX: glowCircle.width /2
                    centerY: glowCircle.width /2
                    centerRadius: glowCircle.width /2
                    focalX: centerX
                    focalY: centerY
                    GradientStop { position: 0; color: "white" }
                    GradientStop { position: 0.2; color: "#10FFFF00" }
                    GradientStop { position: 0.4; color: "#30FFFF00" }
                    GradientStop { position: 0.5; color: "#50FFFF00" }
                    GradientStop { position: 0.6; color: "#30FFFF00" }
                    GradientStop { position: 0.8; color: "#10FFFF00" }
                    GradientStop { position: 1; color: "white" }
                }
                startX: glowCircle.width /2
                startY: 0
                PathArc{
                    useLargeArc: true
                    radiusX: glowCircle.width / 2
                    radiusY: glowCircle.width / 2
                    x:glowCircle.width / 2
                    y:glowCircle.width
                }
                PathArc{
                    useLargeArc: true
                    radiusX: glowCircle.width / 2
                    radiusY: glowCircle.width / 2
                    x:glowCircle.width /2
                    y:0
                }
            }
        }

        PropertyAnimation{
            duration: 1000
            property: 'width'
            target: glowRect
            to: root.width * 3
            running: true
            onStopped: {
                glowRect.visible = false
            }
        }
    }
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

砖农L

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值