一、描述
此类型用于为两个项目设置掩码。
二、使用示例
import QtQuick
import Qt5Compat.GraphicalEffects
Item {
width: 300
height: 300
Image {
id: bug
source: "images/bug.jpg"
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
}
Image {
id: mask
source: "images/butterfly.png"
sourceSize: Qt.size(parent.width, parent.height)
smooth: true
visible: false
}
OpacityMask {
anchors.fill: bug
source: bug
maskSource: mask
}
}
三、属性成员
1、cached : bool
是否允许缓存效果输出像素以提高渲染性能。默认为 false。
每次更改源或效果属性时,都必须更新缓存中的像素。 内存消耗增加,因为需要额外的内存缓冲区来存储效果输出。
建议在源或效果属性动画时禁用缓存。
注意:不支持让效果包含自身,例如通过将 maskSource 设置为效果的父级。
2、invert : bool
此属性控制 sourceMask 的 alpha 值的行为方式。默认为 false。
如果此属性为 false,则生成的不透明度是源 alpha 乘以掩码 alpha,As * Am。
如果此属性为真,则生成的不透明度是源 alpha 乘以掩码 alpha 的倒数 As * (1 - Am)。
3、maskSource : variant
将用作掩码的项目。 掩码项被渲染到一个中间像素缓冲区中,结果中的 alpha 值用于确定源项在显示中的像素可见性。
4、source : variant
将被掩藏的源项。
注意:不支持让效果包含自身,例如通过将源设置为效果的父级。