DNDGamePlayer: Electron редактор сцен, презентация, упаковка electron-builder
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Растеризует app-logo.svg в app-window-icon.png для nativeImage (Windows).
|
||||
* Запуск: node scripts/gen-window-icon.mjs
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { Resvg } from '@resvg/resvg-js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.join(__dirname, '..');
|
||||
const svgPath = path.join(root, 'app', 'renderer', 'public', 'app-logo.svg');
|
||||
const outPath = path.join(root, 'app', 'renderer', 'public', 'app-window-icon.png');
|
||||
|
||||
const svg = fs.readFileSync(svgPath);
|
||||
const resvg = new Resvg(svg, {
|
||||
fitTo: { mode: 'width', value: 256 },
|
||||
});
|
||||
const out = resvg.render();
|
||||
fs.writeFileSync(outPath, out.asPng());
|
||||
console.log('wrote', outPath, out.width, 'x', out.height);
|
||||
|
||||
const buildDir = path.join(root, 'build');
|
||||
fs.mkdirSync(buildDir, { recursive: true });
|
||||
const packIconPath = path.join(buildDir, 'icon.png');
|
||||
const resvg512 = new Resvg(svg, {
|
||||
fitTo: { mode: 'width', value: 512 },
|
||||
});
|
||||
const packOut = resvg512.render();
|
||||
fs.writeFileSync(packIconPath, packOut.asPng());
|
||||
console.log('wrote', packIconPath, packOut.width, 'x', packOut.height, '(electron-builder)');
|
||||
Reference in New Issue
Block a user