diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-08 21:32:11 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-08 21:32:11 +1000 |
| commit | ce7e84aefc8d65ad37327fee4105332de614bbf3 (patch) | |
| tree | 1bf21aad2424d0138fed77835d1c0f4558d1da32 /services/Colours.qml | |
| parent | internal: colour fixes (diff) | |
| download | caelestia-shell-ce7e84aefc8d65ad37327fee4105332de614bbf3.tar.gz caelestia-shell-ce7e84aefc8d65ad37327fee4105332de614bbf3.tar.bz2 caelestia-shell-ce7e84aefc8d65ad37327fee4105332de614bbf3.zip | |
internal: better transparency
Diffstat (limited to 'services/Colours.qml')
| -rw-r--r-- | services/Colours.qml | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/services/Colours.qml b/services/Colours.qml index cb0f634..aef2da3 100644 --- a/services/Colours.qml +++ b/services/Colours.qml @@ -20,13 +20,24 @@ Singleton { readonly property M3Palette current: M3Palette {} readonly property M3Palette preview: M3Palette {} readonly property Transparency transparency: Transparency {} + readonly property color wallColour: quantizer.colors[0] ?? "black" + + function getLuminance(c: color): real { + if (c.r == 0 && c.g == 0 && c.b == 0) + return 0; + return Math.sqrt(0.299 * (c.r ** 2) + 0.587 * (c.g ** 2) + 0.114 * (c.b ** 2)); + } function alterColour(c: color, a: real, layer: int): color { - const luminance = Math.sqrt(0.299 * (c.r ** 2) + 0.587 * (c.g ** 2) + 0.114 * (c.b ** 2)); - const scale = (luminance + (!light || layer == 1 ? 1 : -layer / 2) * (light ? 0.1 : 0.3) * (1 - transparency.base)) / luminance; + const wallLuminance = getLuminance(wallColour); + const luminance = getLuminance(c); + + const offset = (!light || layer == 1 ? 1 : -layer / 2) * (light ? 0.2 : 0.3) * (1 - transparency.base) * (1 + wallLuminance * (light ? 3 : 2.5)); + const scale = (luminance + offset) / luminance; const r = Math.max(0, Math.min(1, c.r * scale)); const g = Math.max(0, Math.min(1, c.g * scale)); const b = Math.max(0, Math.min(1, c.b * scale)); + return Qt.rgba(r, g, b, a); } @@ -73,10 +84,18 @@ Singleton { onLoaded: root.load(text(), false) } + ColorQuantizer { + id: quantizer + + source: Qt.resolvedUrl(Wallpapers.current) + depth: 0 + rescaleSize: 128 + } + component Transparency: QtObject { property bool enabled: false property real base: 0.8 - property real layers: 0.75 + property real layers: 0.4 } component M3TPalette: QtObject { |