Files
tsumugu/frontend/brand/render.mjs
T
LarsandCursor 448e9a06ff
Deploy Development / deploy (push) Successful in 33s
Test Suite / pytest-backend (push) Successful in 56s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 9s
Oeffne Kapitel und Dokument auf derselben Arbeitsflaeche, damit Pfad, Rechte und eigene Reihenfolge beim Lesen erhalten bleiben.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-17 14:19:06 +02:00

164 lines
7.3 KiB
JavaScript

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: `
<path fill="currentColor" opacity=".72" d="M37.2 25.2h11.2v13.2h-1.8V27.4H38.6z"/>
<path fill="currentColor" d="M22.8 29.2h8.8l1.7 2.2h10.2V44H22.8z"/>
<path fill="currentColor" opacity=".45" d="M26.2 34.2h6.4v1.3h-6.4zm0 2.8h4.5v1.3h-4.5z"/>`,
tsumuguSmall: `
<path fill="currentColor" d="M20 28.5h10l2 2.4h12V46H20z"/>
<path fill="currentColor" opacity=".7" d="M34 24h12v12h-2.2V27.2H35.6z"/>`,
mitai: `
<g fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<circle cx="32" cy="22.5" r="2.3" fill="currentColor" stroke="none"/>
<path d="M32 25v6.5M27.2 28.2 32 30.2l4.8-2M32 31.5 28.6 39M32 31.5l3.4 7.5"/>
<path d="M18.5 41.5h5.2l1.7-3.6 1.8 5.2 2-6.2 1.7 4.6h8.2"/>
</g>`,
shinkan: `
<g fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<circle cx="25.5" cy="24" r="2.2" fill="currentColor" stroke="none"/>
<path d="M25.5 26.4 29 31.2l4.2-2.2M29 31.2 24.2 37.2M29 31.2l4.6 2.2 1.8 5.2"/>
<rect x="37.5" y="26.5" width="9.5" height="12" rx="1.2"/>
<path d="M39.6 30h5.4M39.6 33h5.4M39.6 36h3.6"/>
</g>`,
kairo: `
<g fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path fill="none" d="M19.5 42.5 27.5 34.5 34.5 38.5 43 25"/>
<circle cx="19.5" cy="42.5" r="2.1" stroke="none"/>
<circle cx="27.5" cy="34.5" r="2.1" stroke="none"/>
<circle cx="34.5" cy="38.5" r="2.1" stroke="none"/>
<circle cx="43" cy="25" r="2.1" stroke="none"/>
<path fill="currentColor" stroke="none" d="M43 23.2h8.2l-2.3 2.6 2.3 2.6H43z"/>
</g>`,
kansho: `
<path fill="currentColor" fill-rule="evenodd" d="M25 34.5c.4-8.2 6.4-13.4 13.2-12.6 2.6.4 4.6 2 5.6 4.2 1.6-.6 3.4-.2 4.2 1.4-.8 1.4-2.2 2-3.6 1.8.4 2.2.2 4.2-.8 5.8-2.4 3.6-6.4 5.4-10.4 5-5.4-.4-8.6-4.2-8.2-10.6z M39.2 27.2l.9 1.8 2 .2-1.5 1.3.5 2-1.9-1.1-1.9 1.1.5-2-1.5-1.3 2-.2z"/>`,
};
function symbolSvg({ glyph, small = false }) {
const ring = small ? ensoSmall : enso;
return `<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none">
<path fill="currentColor" d="${ring}"/>
${glyph}
</svg>
`;
}
function iconSvg(glyph, { maskable = false } = {}) {
const scale = maskable ? 0.62 : 0.74;
const offset = (64 - 64 * scale) / 2;
return `<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<rect width="64" height="64" fill="#085041"/>
<g transform="translate(${offset.toFixed(2)} ${offset.toFixed(2)}) scale(${scale})" color="#9FE1CB">
<path fill="currentColor" d="${enso}"/>
${glyph}
</g>
</svg>
`;
}
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"), `<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<path fill="#085041" d="${enso}"/>
</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 = `<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 220">
<rect width="360" height="220" rx="28" fill="#085041"/>
<g transform="translate(118 28) scale(1.9)" color="#9FE1CB">
<path fill="currentColor" d="${enso}"/>
${glyph}
</g>
<text x="180" y="176" text-anchor="middle" font-family="Segoe UI, sans-serif" font-size="28" font-weight="700" fill="#f7fbf8">${title}</text>
<text x="180" y="200" text-anchor="middle" font-family="Segoe UI, sans-serif" font-size="14" fill="#9FE1CB">${subtitle}</text>
</svg>
`;
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");