Attempt to round image with mask

This commit is contained in:
quadbyte 2025-08-11 23:48:09 -04:00
parent 1e0057dcaf
commit 81382b213c
4 changed files with 65 additions and 12 deletions

55
Widgets/NImageRounded.qml Normal file
View file

@ -0,0 +1,55 @@
import QtQuick
import QtQuick.Effects
import Quickshell
import Quickshell.Widgets
import qs.Services
Rectangle {
readonly property real scaling: Scaling.scale(screen)
property string imagePath: ""
property string fallbackIcon: ""
anchors.fill: parent
anchors.margins: Style.marginTiniest * scaling
Image {
id: img
anchors.fill: parent
source: imagePath
visible: false
mipmap: true
smooth: true
asynchronous: true
fillMode: Image.PreserveAspectCrop
}
MultiEffect {
anchors.fill: parent
source: img
maskEnabled: true
maskSource: mask
visible: imagePath !== ""
}
Item {
id: mask
anchors.fill: parent
layer.enabled: true
visible: false
Rectangle {
anchors.fill: parent
radius: img.width * 0.5
}
}
// Fallback icon
NText {
anchors.centerIn: parent
text: fallbackIcon
font.family: "Material Symbols Outlined"
font.pointSize: Style.fontSizeXL * scaling
visible: fallbackIcon !== undefined && fallbackIcon !== "" && (source === undefined || source === "")
z: 0
}
}