配色好难处理啊,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();
});
@mashiro 需求是提取突出的颜色?ColorThief好像没有node-vibrant好用
@mashiro 已经很棒了!