Css 如何在QML(QT-Creator)中使用辉光脉动效果使元素具有动画效果?
我想在QML/Qt中复制一个CSS动作,如何在QML(Qt Creator)中使按钮(或任何其他元素)动画化以产生脉动效果,如以下CSS:Css 如何在QML(QT-Creator)中使用辉光脉动效果使元素具有动画效果?,css,qt,animation,qml,qt-quick,Css,Qt,Animation,Qml,Qt Quick,我想在QML/Qt中复制一个CSS动作,如何在QML(Qt Creator)中使按钮(或任何其他元素)动画化以产生脉动效果,如以下CSS: @import "bourbon"; $n:6; $w:20px;//dot size $e:4;//dot margin factor $hsl:160;//start color $bg:#333; html{ background:$bg; height: 100%; backface-visibility: hidden; }
@import "bourbon";
$n:6;
$w:20px;//dot size
$e:4;//dot margin factor
$hsl:160;//start color
$bg:#333;
html{
background:$bg;
height: 100%;
backface-visibility: hidden;
}
#c{
position: absolute;
top:50%;
left:50%;
margin-left: -(($n - 1)*($w + $w*$e))/2 - ($w/2);
}
@mixin shadow($b,$s,$sm,$c){
box-shadow:
0 0 8px 6px $c,
0 0 $b $s $bg,
0 0 $b ($s + $sm) $c;
}
.s{
width: $w;
height: $w;
border-radius: 50%;
cursor:pointer;
float: left;
@include transition(all .2s);
&:nth-child(n+2){
margin-left: $w*$e;
}
}
@for $i from 0 to $n {
$c:hsl($hsl+(10*$i),100%,55%);
$c2:hsl((6*$i),100%,55%);
.s:nth-child(#{$i+1}){
background: lighten($c,5%);
@include animation(r+$i 2s ($i/4)+s ease-out infinite); &:hover{
background: lighten($c2,5%);
@include animation(r2+$i .5s .4s ease-out infinite);
}
}
@include keyframes(r+$i) {
0%{@include shadow(0px,0px,0px,rgba($c,0));}
10%{@include shadow(12px,10px,4px,$c);}
100%{@include shadow(0px,40px,0px,rgba($c,0));}
}
@include keyframes(r2+$i) {
from{@include shadow(12px,10px,4px,$c2);}
to{@include shadow(4px,40px,1px,rgba($c2,0));}
}
}
我试过使用StyleEngine。
此外,我还尝试使用外部css文件,但没有运气 可以设置渐变动画以产生一些辉光效果。因为5.10有,所以你可以用它。我不擅长绘画,但我的想法如下:
import QtQuick 2.10
import QtQuick.Window 2.2
import QtQuick.Shapes 1.0
Window {
id: window
title: "Test"
visible: true
width: 400
height: 400
Shape {
width: 100
height: 100
anchors.centerIn: parent
ShapePath {
strokeWidth: 2
strokeColor: "transparent"
startX: 50; startY: 0
fillGradient: RadialGradient {
id: gradient
property real pos: 0.3
centerX: 50;
centerY: 50
centerRadius: 50
focalX: centerX; focalY: centerY
GradientStop { position: 0; color: "#33ffbb" }
GradientStop { position: 0.2; color: "#33ffbb" }
GradientStop { position: 0.25; color: "transparent" }
GradientStop { position: gradient.pos - 0.1; color: "transparent" }
GradientStop { position: gradient.pos; color: "#33ffbb" }
GradientStop { position: gradient.pos + 0.1; color: "transparent" }
}
PathArc {
x: 50
y: 100
radiusX: 50
radiusY: 50
useLargeArc: true
}
PathArc {
x: 50
y: 0
radiusX: 50
radiusY: 50
useLargeArc: true
}
}
PropertyAnimation {
target: gradient
property: "pos"
from: 0.3
to: 0.9
duration: 1500
loops: Animation.Infinite
easing.type: Easing.OutQuad
running: true
}
}
}
您可以使用值来获得接近示例的效果。您可以设置渐变动画以产生一些辉光效果。因为5.10有,所以你可以用它。我不擅长绘画,但我的想法如下:
import QtQuick 2.10
import QtQuick.Window 2.2
import QtQuick.Shapes 1.0
Window {
id: window
title: "Test"
visible: true
width: 400
height: 400
Shape {
width: 100
height: 100
anchors.centerIn: parent
ShapePath {
strokeWidth: 2
strokeColor: "transparent"
startX: 50; startY: 0
fillGradient: RadialGradient {
id: gradient
property real pos: 0.3
centerX: 50;
centerY: 50
centerRadius: 50
focalX: centerX; focalY: centerY
GradientStop { position: 0; color: "#33ffbb" }
GradientStop { position: 0.2; color: "#33ffbb" }
GradientStop { position: 0.25; color: "transparent" }
GradientStop { position: gradient.pos - 0.1; color: "transparent" }
GradientStop { position: gradient.pos; color: "#33ffbb" }
GradientStop { position: gradient.pos + 0.1; color: "transparent" }
}
PathArc {
x: 50
y: 100
radiusX: 50
radiusY: 50
useLargeArc: true
}
PathArc {
x: 50
y: 0
radiusX: 50
radiusY: 50
useLargeArc: true
}
}
PropertyAnimation {
target: gradient
property: "pos"
from: 0.3
to: 0.9
duration: 1500
loops: Animation.Infinite
easing.type: Easing.OutQuad
running: true
}
}
}
你可以玩数值游戏来获得接近你的例子的效果。我只需要用一个按钮或矢量svg来代替你的形状,同样,如果说元素不是径向的,我们可以用什么来代替径向梯度?@VaibhavSrivastava不,你应该使用
DropShadow
或Glow
来实现这个效果。看起来很不错,但是,由于某些原因,Map
元素无法正常工作-在平移/缩放时更改其位置。我只需要使用按钮或矢量svg来代替您的形状,同样,如果元素不是径向的,我们可以使用什么来代替径向梯度?@VaibhavSrivastava No,你应该使用DropShadow
或Glow
来实现这一点。看起来很不错,但是由于某些原因,在Map
元素上无法正常工作-更改其在平移/缩放上的位置。我在这里共享一支笔--我在这里共享一支笔--