feat(UI): update logo
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import sharp from "sharp";
|
||||
|
||||
const light = await readFile("public/icons/brand.svg", "utf8");
|
||||
const dark = light.replaceAll("#087f83", "#4dc9be").replaceAll("#9ddfc9", "#d0f5e7");
|
||||
await writeFile("public/icons/brand-dark.svg", dark, "utf8");
|
||||
|
||||
const { data, info } = await sharp(Buffer.from(dark)).resize(1024, 1024).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const colors = [[77, 201, 190], [208, 245, 231]];
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
if (data[i + 3] === 0) continue;
|
||||
const color = colors.reduce((closest, candidate) => {
|
||||
const distance = candidate.reduce((sum, channel, index) => sum + (channel - data[i + index]) ** 2, 0);
|
||||
return distance < closest.distance ? { value: candidate, distance } : closest;
|
||||
}, { value: colors[0], distance: Infinity }).value;
|
||||
for (let channel = 0; channel < 3; channel++) data[i + channel] = color[channel];
|
||||
}
|
||||
const icon = await sharp(data, { raw: info }).png().toBuffer();
|
||||
await sharp(icon).toFile("public/icons/brand-dark-transparent.png");
|
||||
await sharp({ create: { width: 1024, height: 1024, channels: 4, background: "#10161f" } })
|
||||
.composite([{ input: icon }]).png().toFile("public/icons/brand-dark-background.png");
|
||||
Reference in New Issue
Block a user