internal: better transparency
This commit is contained in:
parent
729bc6f6f1
commit
ce7e84aefc
1 changed files with 22 additions and 3 deletions
|
|
@ -20,13 +20,24 @@ Singleton {
|
||||||
readonly property M3Palette current: M3Palette {}
|
readonly property M3Palette current: M3Palette {}
|
||||||
readonly property M3Palette preview: M3Palette {}
|
readonly property M3Palette preview: M3Palette {}
|
||||||
readonly property Transparency transparency: Transparency {}
|
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 {
|
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 wallLuminance = getLuminance(wallColour);
|
||||||
const scale = (luminance + (!light || layer == 1 ? 1 : -layer / 2) * (light ? 0.1 : 0.3) * (1 - transparency.base)) / luminance;
|
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 r = Math.max(0, Math.min(1, c.r * scale));
|
||||||
const g = Math.max(0, Math.min(1, c.g * scale));
|
const g = Math.max(0, Math.min(1, c.g * scale));
|
||||||
const b = Math.max(0, Math.min(1, c.b * scale));
|
const b = Math.max(0, Math.min(1, c.b * scale));
|
||||||
|
|
||||||
return Qt.rgba(r, g, b, a);
|
return Qt.rgba(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,10 +84,18 @@ Singleton {
|
||||||
onLoaded: root.load(text(), false)
|
onLoaded: root.load(text(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ColorQuantizer {
|
||||||
|
id: quantizer
|
||||||
|
|
||||||
|
source: Qt.resolvedUrl(Wallpapers.current)
|
||||||
|
depth: 0
|
||||||
|
rescaleSize: 128
|
||||||
|
}
|
||||||
|
|
||||||
component Transparency: QtObject {
|
component Transparency: QtObject {
|
||||||
property bool enabled: false
|
property bool enabled: false
|
||||||
property real base: 0.8
|
property real base: 0.8
|
||||||
property real layers: 0.75
|
property real layers: 0.4
|
||||||
}
|
}
|
||||||
|
|
||||||
component M3TPalette: QtObject {
|
component M3TPalette: QtObject {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue