diff options
| author | Freya Murphy <freya@freyacat.org> | 2026-03-17 08:38:19 -0400 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2026-03-17 08:38:19 -0400 |
| commit | 8a66bf59e58aa4c2ddcae55f59d6206772566193 (patch) | |
| tree | 95609a10bad6cfcfc67a66051d57ec29f1469630 /services | |
| parent | make colors work better (diff) | |
| download | caelestia-shell-8a66bf59e58aa4c2ddcae55f59d6206772566193.tar.gz caelestia-shell-8a66bf59e58aa4c2ddcae55f59d6206772566193.tar.bz2 caelestia-shell-8a66bf59e58aa4c2ddcae55f59d6206772566193.zip | |
make color rendering better, wth was the orig doing
Diffstat (limited to 'services')
| -rw-r--r-- | services/Colours.qml | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/services/Colours.qml b/services/Colours.qml index e83e353..26f666b 100644 --- a/services/Colours.qml +++ b/services/Colours.qml @@ -20,31 +20,18 @@ Singleton { readonly property M3TPalette tPalette: M3TPalette {} readonly property M3Palette defaultPalette: M3Palette {} readonly property Transparency transparency: Transparency {} - readonly property alias wallLuminance: analyser.luminance - - 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 = getLuminance(c); - - const offset = (!light || layer == 1 ? 1 : -layer / 2) * (light ? 0.2 : 0.3) * (1 - transparency.base) * (1 + wallLuminance * (light ? (layer == 1 ? 3 : 1) : 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); - } function layer(c: color, layer: var): color { if (!transparency.enabled) return c; - return layer === 0 ? Qt.alpha(c, transparency.base) : alterColour(c, transparency.layers, layer ?? 1); + const maxLayer = 2; + layer = Math.min(layer ?? 1, maxLayer); + + const offset = 1 - transparency.base; + const alpha = transparency.base + offset * layer * (1/maxLayer); + + return Qt.alpha(c, alpha); } function on(c: color): color { |