我不知道如何模糊我的窗口的背景(有点像CSS中的backdrop-filter: blur
)。
显然,我必须使用一个叫做ShaderEffect的东西,但是我不知道如何编写着色器。
我找到了以下高斯模糊的代码,我认为这是合适的,但是我如何将它放到我的项目中呢?
https://www.shadertoy.com/view/Xltfzj
我想要这样的图片:
发布于 2021-10-19 15:48:57
这实际上并不是一件容易的事情,因为你不希望你的模糊对象是将要被模糊的项目的子对象。否则,它将试图模糊自己。这里有一些东西可以给你大体的概念。
Item {
id: window
Image {
id: background
anchors.fill: parent
source: "someImg.jpg"
}
// This can't be a child of `background`
Item {
id: clipRect
anchors.centerIn: parent
width: 300
height: 300
clip: true
// We want the blur object to fill the background
// but be clipped to its parent
FastBlur {
x: -parent.x
y: -parent.y
width: background.width
height: background.height
source: background
radius: 64
}
// Just to put a border around the blur
Rectangle {
anchors.fill: parent
color: "transparent"
border.color: "orange"
border.width: 2
}
}
}
发布于 2021-10-19 03:20:39
如果你想在CSS中模糊一张图片,你需要转到图片或类的样式并做filter: blur(radius);
半径是您希望模糊的大小。你必须记得把'px‘放在半径后面,例如filter: blur(8px);
您也可以将其作为rem而不是px放入。在您提供的链接上有一个快速说明:它不是CSS语言。您不一定需要着色器效果才能使其工作。
如果您确实想使用着色器,那么请等待其他人的回复:)
https://stackoverflow.com/questions/69624657
复制相似问题