与 OpacityMask 相对 [英] Opposite for OpacityMask

查看:63
本文介绍了与 OpacityMask 相对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它用另一个项目遮住了源项目,因此源仅在遮罩不透明的地方可见.如何使源仅在蒙版透明的地方可见?

It masks the source item with another item, so the source is visible only where the mask is opaque. How to make source visible only where the mask is transparent?

目前它是用着色器完成的,但我想替换它.

Currently it's done with a shader, but I want to replace that.

无法反转掩码,因为它由多个图像组成:单个反转图像的总和与总和的反转不同.

Can't invert the mask, because it consists of multiple images: the sum of individually inverted images is not the same as the inversion of the sum.

推荐答案

Qt 没有任何组件可以满足您的需求.OpacityMask 最接近您的需要.您可以在官方存储库上此处查看其代码或者在你的机器上的这个路径:Qt_folder/Qt_version/Qt_kit/qml/QtGraphicalEffects/OpacityMask.qml.这样您就可以轻松浏览所有 QtGraphicalEffects 组件的来源.

There is no component made by Qt that can do what you need. OpacityMask is closest to what you need. You can view its code here on the official repository or on your machine in this path: Qt_folder/Qt_version/Qt_kit/qml/QtGraphicalEffects/OpacityMask.qml. This way you can easily browse the source of all QtGraphicalEffects components.

使用 ShaderEffect 是完成任务的不错选择.

Using ShaderEffect is a good choice for the task.

正如 GrecKo 指出的那样,OpacityMask<中已经有一个 invert 属性/代码> 对象.它将在 Qt 5.7 中可用,但代码已在上面的链接中可用.您可以等待更新或下载组件并在您的项目中使用它.

As GrecKo pointed out there already is an invert property in OpacityMask object. It will be available with Qt 5.7 but the code is already available in the link above. You can either wait for the update or download the component and use it in your project.

这篇关于与 OpacityMask 相对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆