这是我到目前为止所拥有的:
- a
RadialGradient
如下图蓝色 - a
Shape
如下图绿色
然而,我想要的是使用RadialGradient
as ,OpacityMask
这样绿色的外环Shape
是 100% 不透明的,但直线应该在图像中间逐渐变细以完全透明。到目前为止,我的任何努力都没有奏效。当我同时设置 theRadialGradient
和Shape
tovisible: false
时,除了要在其中绘制所需图像的黑匣子外,我什么也得不到。
一个理想的答案还可以解释如何解决此类问题以解决问题。
import QtQuick 2.15
import QtQuick.Shapes 1.15
import QtGraphicalEffects 1.15
import QtQuick.Layouts 1.2
import QtQuick.Controls 2.15
import QtQuick.Dialogs 1.1
Rectangle {
id: myFrame
width: 640
height: 640
Rectangle {
id: blackbox
anchors.centerIn: parent
anchors.fill: parent
color: "black"
layer.enabled: true
layer.samples: 8
RadialGradient {
id: mask
visible: true
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0.0; color: "transparent" }
GradientStop { position: 0.4; color: "blue" }
}
}
Shape {
id: myShape
x: parent.width / 2
y: parent.width / 2
visible: true
ShapePath {
fillColor: "transparent"
strokeColor: Qt.rgba(0.318, 1, 0.051, 0.9)
strokeWidth: blackbox.height * 0.02
capStyle: ShapePath.RoundCap
joinStyle: ShapePath.RoundJoin
startX: 0
startY: 0
PathAngleArc {
radiusX: 0.46 * blackbox.width
radiusY: 0.46 * blackbox.height
startAngle: 270
sweepAngle: -360 * 0.7
moveToStart: false
}
}
}
OpacityMask {
anchors.fill: parent
source: myShape
maskSource: mask
}
}
}