mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-24 12:35:05 +00:00
IMP: try to avoid black/white colors extracted from cover
This commit is contained in:
parent
dfc2c79921
commit
b610a0dd8b
1 changed files with 12 additions and 4 deletions
|
|
@ -696,12 +696,20 @@ async function pickCoverColor(img) {
|
|||
|
||||
$("html").css("--image-brightness", getImageLightness(img) / 255);
|
||||
|
||||
sidebarColor = "#509bf5";
|
||||
if (img.complete) {
|
||||
sidebarColor = chroma(colorThief.getColor(img)).hex();
|
||||
} else {
|
||||
sidebarColor = "#509bf5";
|
||||
const dominant = colorThief.getColor(img);
|
||||
let palette = colorThief.getPalette(img);
|
||||
palette.unshift(dominant);
|
||||
sidebarColor = chroma(dominant).hex();
|
||||
for (const col of palette) {
|
||||
const chrmCol = chroma(col);
|
||||
if (chrmCol.luminance() > 0.05 && chrmCol.luminance() < 0.9) {
|
||||
sidebarColor = chrmCol.hex();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateColors(sidebarColor);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue