liquid-ass/GlassSurface.qml
2025-06-10 13:52:54 -04:00

85 lines
2.2 KiB
QML

import QtQuick
import Quickshell.Widgets
import Qt5Compat.GraphicalEffects
ClippingRectangle {
id: root
color: "transparent"
border.width: 1
border.color: Qt.rgba(1, 1, 1, 0.1)
property var source
property real time: 0.5
property real strength: 0.3
property real speed: 0.25
property real scale: 3.0
property real edgeReflectionStrength: 0.2
property real edgeReflectionWidth: 0
// Blur
ShaderEffectSource {
id: blurredBackground
anchors.fill: parent
sourceItem: root.source
sourceRect: Qt.rect(root.x, root.y, root.width, root.height)
hideSource: false
live: true
}
FastBlur {
id: backgroundBlur
anchors.fill: parent
source: blurredBackground
radius: 16
transparentBorder: true
}
// Liquid glass shader warp
ShaderEffect {
anchors.fill: parent
fragmentShader: "root:shaders/liquid-glass.frag.qsb"
property real time: root.time
property real flowSpeed: root.speed
property real warpStrength: root.strength
property real scale: root.scale
property real edgeReflectionStrength: root.edgeReflectionStrength
property real edgeReflectionWidth: root.edgeReflectionWidth
property variant source: ShaderEffectSource {
sourceItem: backgroundBlur
hideSource: false
live: true
}
}
// Subtle glass overlay
Rectangle {
anchors.fill: parent
color: "transparent"
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 1
height: parent.height * 0.3
radius: parent.radius - 1
gradient: Gradient {
GradientStop {
position: 0.0
color: Qt.rgba(1, 1, 1, 0.08)
}
GradientStop {
position: 0.5
color: Qt.rgba(1, 1, 1, 0.0)
}
GradientStop {
position: 1.0
color: Qt.rgba(1, 1, 1, 0.0)
}
}
}
}
}