配色好难处理啊,MDC的primaryColor和secondaryColor到底是怎么调出来的?目前只能做到这个水平了
const image = new Image();
image.crossOrigin = "anonymous";
image.src = this.$props.song.thumbnail;
image.addEventListener("load", async (event) => {
const colorThief = new ColorThief();
let color = await colorThief.getColor(image);
const contrast = chroma.contrast(chroma(...color).hex(), "#ffffff");
if (contrast < 4) return;
this.primaryColor = chroma(...color).hex();
this.secondaryColor = chroma(...color)
.brighten()
.hex();
this.darkColor = chroma(...color)
.darken()
.hex();
this.lightColor = chroma(...color)
.brighten(2.5)
.hex();
});
Chinese 🇨🇳 / Dictatorial Admin / Mastodon Code Contributor / 摸鱼技术布道师
Steam: https://steamcommunity.com/id/MashiroBest
Epic: https://store.epicgames.com/en-US/u/d211c824cbd94aaeba898db6bb823ff7
原批交流群:966322309