Created
July 2, 2018 06:40
-
-
Save mitchcurtis/56e3de5c45e0ce137f24e7d981cd6271 to your computer and use it in GitHub Desktop.
OpacityMask cutout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.0 | |
import QtQuick.Window 2.0 | |
import QtGraphicalEffects 1.0 | |
Window { | |
id: window | |
width: 400 | |
height: 400 | |
visible: true | |
Flickable { | |
id: flickable | |
width: 100 | |
height: 100 | |
contentWidth: content.implicitWidth | |
contentHeight: content.implicitHeight | |
anchors.centerIn: parent | |
Rectangle { | |
id: content | |
width: 128 | |
height: 128 | |
color: "steelblue" | |
} | |
} | |
Rectangle { | |
id: bg | |
anchors.fill: parent | |
color: "#aa000000" | |
visible: false | |
} | |
Item { | |
id: cutout | |
anchors.fill: parent | |
visible: false | |
Rectangle { | |
width: flickable.width | |
height: flickable.height | |
anchors.centerIn: parent | |
} | |
} | |
OpacityMask { | |
anchors.fill: bg | |
source: bg | |
maskSource: cutout | |
invert: true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment