Files
Toolbox/public/tools/zen_box/generate-icons.js
T

35 lines
1.9 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const svgIcon = `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<rect width="100" height="100" rx="20" fill="#060612"/>
<circle cx="50" cy="44" r="32" stroke="#e8b86d" stroke-width="1.2" opacity="0.25" fill="none"/>
<path d="M33 66 C24 65 16 70 14 78 C12 84 16 88 24 87 C32 86 42 79 44 72 L44 67 Z" fill="#e8e6f0"/>
<path d="M67 66 C76 65 84 70 86 78 C88 84 84 88 76 87 C68 86 58 79 56 72 L56 67 Z" fill="#e8e6f0"/>
<path d="M44 67 C44 67 40 58 40 50 C40 40 44 34 48 30 L50 29 L52 30 C56 34 60 40 60 50 C60 58 56 67 56 67 C53 74 47 74 44 67 Z" fill="#e8e6f0"/>
<ellipse cx="50" cy="72" rx="10" ry="4" fill="#e8e6f0"/>
<rect x="46" y="25" width="8" height="7" rx="2" fill="#e8e6f0"/>
<ellipse cx="50" cy="17" rx="11" ry="12" fill="#e8e6f0"/>
<ellipse cx="50" cy="6" rx="5" ry="4" fill="#e8e6f0"/>
<path d="M34 36 Q28 33 28 29 Q28 25 34 22" stroke="#e8b86d" stroke-width="1.2" stroke-linecap="round" fill="none" opacity="0.7"/>
<path d="M66 36 Q72 33 72 29 Q72 25 66 22" stroke="#e8b86d" stroke-width="1.2" stroke-linecap="round" fill="none" opacity="0.7"/>
<circle cx="50" cy="7" r="1.5" fill="#e8b86d"/>
</svg>
`;
// 使用 Node.js 自带的方式生成图标
// 这里我们先创建临时 SVG 文件,然后可以通过浏览器或其他工具转换
const svgPath = path.join(__dirname, 'icon.svg');
fs.writeFileSync(svgPath, svgIcon.trim(), 'utf8');
console.log('SVG icon generated at:', svgPath);
console.log('To convert to PNG, you can use online tools or ImageMagick:');
console.log(' convert icon.svg -resize 192x192 icon-192.png');
console.log(' convert icon.svg -resize 512x512 icon-512.png');
console.log(' convert icon.svg -resize 180x180 apple-touch-icon.png');
// 我们也可以用 base64 方式提供SVG作为临时方案
const svgBase64 = Buffer.from(svgIcon.trim()).toString('base64');
console.log('SVG base64 ready');