MonEspacePro/docs/app-android/store/render.js

40 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Visuels Google Play : 5 captures 1080 × 1920, image de présentation 1024 × 500 et icône 512 × 512.
// Réutilise playwright-core installé pour les visuels App Store : cd ../../app-ios/store && npm install, puis node render.js
const path = require('path');
const fs = require('fs');
const { pathToFileURL } = require('url');
const { chromium } = require(path.join(__dirname, '../../app-ios/store/node_modules/playwright-core'));
const W = 1080, H = 1920, NAMES = ['01-carte', '02-tampon', '03-recompenses', '04-statistiques', '05-campagnes'];
async function open(browser, file, width, height, scale = 1) {
const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: scale });
await page.goto(pathToFileURL(path.join(__dirname, file)).href);
await page.evaluate(() => document.fonts.ready);
await page.waitForLoadState('networkidle');
return page;
}
(async () => {
const out = path.join(__dirname, 'export');
fs.mkdirSync(out, { recursive: true });
const browser = await chromium.launch({ executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe', headless: true });
const page = await open(browser, 'captures.html', W * NAMES.length, H);
for (const [i, name] of NAMES.entries()) {
await page.screenshot({ path: path.join(out, `${name}.png`), clip: { x: i * W, y: 0, width: W, height: H } });
}
await page.screenshot({ path: path.join(out, 'apercu-panorama.jpg'), type: 'jpeg', quality: 85 });
const feature = await open(browser, 'feature.html', 1024, 500);
await feature.screenshot({ path: path.join(out, 'presentation.png') });
// Icône 512 × 512 : l'icône de l'app, sans transparence.
const icon = await browser.newPage({ viewport: { width: 512, height: 512 } });
const src = 'data:image/png;base64,' + fs.readFileSync(path.join(__dirname, '../../../pro/assets/icon.png')).toString('base64');
await icon.setContent(`<body style="margin:0;background:#0E7A66"><img src="${src}" style="display:block;width:512px;height:512px"></body>`);
await icon.screenshot({ path: path.join(out, 'icone-512.png') });
await browser.close();
console.log(`Visuels Google Play dans ${out}`);
})();