// Generates PWA icon PNGs from an SVG template using sharp. // Run: node scripts/generate-icons.mjs import sharp from "sharp"; import { writeFileSync } from "fs"; import path from "path"; import { fileURLToPath } from "url"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const outDir = path.join(__dirname, "../public/icons"); // Brand colors from the app const BG = "#fb7185"; // rose-400 // SVG template — rounded square with cherry blossom character. // For maskable: full bleed background, content within safe zone (inner 80%). function makeSvg(size, maskable = false) { const radius = maskable ? 0 : Math.round(size * 0.18); const fontSize = maskable ? Math.round(size * 0.48) : Math.round(size * 0.56); const y = maskable ? Math.round(size * 0.68) : Math.round(size * 0.72); return ` T `; } const icons = [ { name: "192.png", size: 192, maskable: false }, { name: "512.png", size: 512, maskable: false }, { name: "maskable-512.png", size: 512, maskable: true }, { name: "apple-180.png", size: 180, maskable: false }, ]; for (const icon of icons) { const svg = Buffer.from(makeSvg(icon.size, icon.maskable)); const outPath = path.join(outDir, icon.name); await sharp(svg).png().toFile(outPath); console.log(`✓ ${icon.name}`); }