import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import sharp from "sharp";
const here = path.dirname(fileURLToPath(import.meta.url));
const publicDir = path.resolve(here, "../public");
const designDir = "C:/Dev/jinkendo-app-design-2026-10-17/assets";
function brushRing(cx, cy, r) {
const start = -0.7;
const end = start + Math.PI * 1.78;
const steps = 96;
const outer = [];
const inner = [];
for (let i = 0; i <= steps; i += 1) {
const u = i / steps;
const angle = start + (end - start) * u;
const taper = Math.sin(Math.PI * u) ** 0.62;
const wave = 0.55 + 0.45 * Math.sin(u * Math.PI * 2.15 + 0.6);
const width = r * 0.2 * taper * wave;
const wobble = 1 + 0.028 * Math.sin(u * Math.PI * 6.2);
const radius = r * wobble;
const x = cx + radius * Math.cos(angle);
const y = cy + radius * Math.sin(angle);
const nx = Math.cos(angle);
const ny = Math.sin(angle);
outer.push([x + nx * width * 0.78, y + ny * width * 0.78]);
inner.push([x - nx * width * 0.28, y - ny * width * 0.28]);
}
const point = (pair) => pair.map((value) => value.toFixed(2)).join(" ");
let d = `M ${point(outer[0])}`;
for (const pair of outer.slice(1)) d += ` L ${point(pair)}`;
for (const pair of inner.reverse()) d += ` L ${point(pair)}`;
return `${d} Z`;
}
const enso = brushRing(32, 32, 22.5);
const ensoSmall = brushRing(32, 32, 23.5);
const glyphs = {
tsumugu: `
`,
tsumuguSmall: `
`,
mitai: `
`,
shinkan: `
`,
kairo: `
`,
kansho: `
`,
};
function symbolSvg({ glyph, small = false }) {
const ring = small ? ensoSmall : enso;
return `
`;
}
function iconSvg(glyph, { maskable = false } = {}) {
const scale = maskable ? 0.62 : 0.74;
const offset = (64 - 64 * scale) / 2;
return `
`;
}
function write(file, contents) {
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, contents);
}
const products = [
["mitai", "Mitai", "Körper und Gesundheit"],
["shinkan", "Shinkan", "Training planen"],
["kairo", "Kairo", "Vorhaben steuern"],
["kansho", "Kanshō", "Reflektieren und verstehen"],
["tsumugu", "Tsumugu", "Unterlagen ordnen"],
];
write(path.join(here, "enso-master.svg"), `
`);
write(path.join(publicDir, "brand/tsumugu-symbol.svg"), symbolSvg({ glyph: glyphs.tsumugu }).replaceAll("currentColor", "#085041"));
write(path.join(publicDir, "brand/tsumugu-symbol-on-dark.svg"), symbolSvg({ glyph: glyphs.tsumugu }).replaceAll("currentColor", "#9FE1CB"));
write(path.join(publicDir, "brand/tsumugu-small.svg"), symbolSvg({ glyph: glyphs.tsumuguSmall, small: true }).replaceAll("currentColor", "#9FE1CB"));
write(path.join(publicDir, "favicon.svg"), iconSvg(glyphs.tsumuguSmall));
write(path.join(here, "../src/enso-path.js"), `export const ENSO_PATH = ${JSON.stringify(enso)};\n`);
for (const [id, title, subtitle] of products) {
const glyph = glyphs[id];
const master = `
`;
write(path.join(designDir, `${id}-master.svg`), master);
write(path.join(designDir, `${id}-symbol-on-dark.svg`), symbolSvg({ glyph }).replaceAll("currentColor", "#9FE1CB"));
write(path.join(designDir, `${id}-symbol-on-light.svg`), symbolSvg({ glyph }).replaceAll("currentColor", "#085041"));
write(path.join(designDir, `${id}-icon.svg`), iconSvg(glyph));
write(path.join(designDir, `${id}-maskable.svg`), iconSvg(glyph, { maskable: true }));
}
async function png(svg, file, size) {
await sharp(Buffer.from(svg)).resize(size, size).png().toFile(file);
}
const tsumuguIcon = iconSvg(glyphs.tsumugu);
const tsumuguMask = iconSvg(glyphs.tsumugu, { maskable: true });
const tsumuguSmallIcon = iconSvg(glyphs.tsumuguSmall);
await png(tsumuguSmallIcon, path.join(publicDir, "favicon-16.png"), 16);
await png(tsumuguSmallIcon, path.join(publicDir, "favicon-32.png"), 32);
await png(tsumuguIcon, path.join(publicDir, "apple-touch-icon.png"), 180);
await png(tsumuguIcon, path.join(publicDir, "icons/icon-192.png"), 192);
await png(tsumuguIcon, path.join(publicDir, "icons/icon-512.png"), 512);
await png(tsumuguMask, path.join(publicDir, "icons/icon-maskable-512.png"), 512);
for (const [id] of products) {
const svg = fs.readFileSync(path.join(designDir, `${id}-icon.svg`));
await png(svg, path.join(designDir, `${id}-32.png`), 32);
await png(svg, path.join(designDir, `${id}-192.png`), 192);
}
console.log("icons written");