mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
tweak colors
This commit is contained in:
@@ -164,13 +164,39 @@ Item {
|
|||||||
ColorQuantizer {
|
ColorQuantizer {
|
||||||
id: colorQuantizer
|
id: colorQuantizer
|
||||||
source: _cqSource !== "" ? _cqSource : undefined
|
source: _cqSource !== "" ? _cqSource : undefined
|
||||||
depth: 6
|
depth: 8
|
||||||
|
rescaleSize: 32
|
||||||
onColorsChanged: {
|
onColorsChanged: {
|
||||||
if (!colors || colors.length === 0) return
|
if (!colors || colors.length === 0) return
|
||||||
const d = colors[Math.min(1, colors.length-1)]
|
|
||||||
const a = colors[Math.min(3, colors.length-1)]
|
function enhanceColor(color) {
|
||||||
_pendingDom = d
|
const satBoost = 1.4
|
||||||
_pendingAcc = a
|
const valueBoost = 1.2
|
||||||
|
return Qt.hsva(color.hsvHue, Math.min(1, color.hsvSaturation * satBoost), Math.min(1, color.hsvValue * valueBoost), color.a)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getExtremeColor(startIdx, direction = 1) {
|
||||||
|
let bestColor = colors[startIdx]
|
||||||
|
let bestScore = 0
|
||||||
|
|
||||||
|
for (let i = startIdx; i >= 0 && i < colors.length; i += direction) {
|
||||||
|
const c = colors[i]
|
||||||
|
const saturation = c.hsvSaturation
|
||||||
|
const brightness = c.hsvValue
|
||||||
|
const contrast = Math.abs(brightness - 0.5) * 2
|
||||||
|
const score = saturation * 0.7 + contrast * 0.3
|
||||||
|
|
||||||
|
if (score > bestScore) {
|
||||||
|
bestScore = score
|
||||||
|
bestColor = c
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return enhanceColor(bestColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
_pendingDom = getExtremeColor(Math.floor(colors.length * 0.2), 1)
|
||||||
|
_pendingAcc = getExtremeColor(Math.floor(colors.length * 0.8), -1)
|
||||||
paletteApplyDelay.restart()
|
paletteApplyDelay.restart()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user