Files
martbost 444b08ddac Promo kit: add 600x300 wide and 250x250 small creatives for all 3 angles
Member request. art.mjs gains layouts for both and ONLY=<shapes> to render
just those.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 09:55:53 -06:00

77 lines
8.8 KiB
JavaScript

// Renders the site art with Playwright (local only), in the watershed look (approved mockup 2026-11-16): the icon, the OG share image,
// the Telegram proof cards (public/art/proof/vas-proof-{river,ink}.png) and the promo kit (public/art/kit/vas-<angle>-<shape>.png,
// 3 angles x 8 shapes, ad-blocker-neutral names). The hero (licensed kie art) and the topo pattern (licensed Envato) are embedded.
// node tools/art.mjs (PLAYWRIGHT = path to the playwright package)
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
const require = createRequire(import.meta.url);
const APP = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const PW = process.env.PLAYWRIGHT || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
const { chromium } = require(PW);
const { SHAPES } = require(path.join(APP, 'promokit.js'));
const ART = path.join(APP, 'public', 'art');
fs.mkdirSync(path.join(ART, 'kit'), { recursive: true }); fs.mkdirSync(path.join(ART, 'proof'), { recursive: true });
const b64 = f => fs.readFileSync(path.join(ART, f)).toString('base64');
const HERO = 'data:image/jpeg;base64,' + b64('hero.jpg'), TOPO = 'data:image/png;base64,' + b64('topo.png');
const FONTS = '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,800&family=IBM+Plex+Sans:wght@500;600&family=IBM+Plex+Mono:wght@500&display=swap">';
const MARK = s => `<svg width="${s}" height="${s}" viewBox="0 0 34 34"><circle cx="17" cy="8" r="5" fill="#C4371B"/><path d="M17 13 V20 M17 20 L8 29 M17 20 L26 29 M17 20 V30" stroke="#0B2730" stroke-width="2.4" fill="none" stroke-linecap="round"/></svg>`;
const MARKL = s => MARK(s).replace('#0B2730', '#EAF6F4');
const CSS = `*{box-sizing:border-box;margin:0}html,body{width:100%;height:100%;overflow:hidden}
body{font-family:'IBM Plex Sans',sans-serif;color:#0B2730;background:#EAF6F4}
.h{font-family:'Bricolage Grotesque',sans-serif;font-weight:800;letter-spacing:-.02em;line-height:1.02}
.m{font-family:'IBM Plex Mono',monospace;font-weight:500;letter-spacing:.12em;text-transform:uppercase}
.wm{font-family:'Bricolage Grotesque',sans-serif;font-weight:800;white-space:nowrap}.wm b{color:#C4371B}
.river{background:linear-gradient(90deg,#EAF6F4 0%,rgba(234,246,244,.92) 38%,rgba(234,246,244,0) 70%),url(${HERO}) right center/cover no-repeat}
.ink{background:#0B2730 url(${TOPO}) repeat;background-size:600px;color:#EAF6F4}.ink .wm b{color:#FF9479}
.btn{display:inline-block;background:#C4371B;color:#fff;border-radius:12px;font-weight:600;white-space:nowrap}`;
const page = (w, h, body, cls) => `<!doctype html><html><head>${FONTS}<style>${CSS}</style></head><body class="${cls || ''}" style="width:${w}px;height:${h}px">${body}</body></html>`;
const ANG = {
free: { k: 'Free text ad', t: 'Every ad has a source.', s: 'Post one free text ad and watch who passes it on.', cta: 'Post your ad free' },
tree: { k: 'Family tree', t: 'Watch your ad travel.', s: 'Every reshare is a branch. See them all.', cta: 'See your tree' },
boost: { k: 'One-time Boost', t: 'Boost the source.', s: 'Top of the reshare board. Never a subscription.', cta: 'Boost my ad' }
};
function kit(angle, shape) {
const [w, h] = SHAPES[shape]; const a = ANG[angle]; const cls = angle === 'boost' ? 'ink' : 'river';
const mk = cls === 'ink' ? MARKL : MARK;
if (h <= 90) { // strips and leaderboards
const fs = Math.round(h * 0.36);
return page(w, h, `<div style="display:flex;align-items:center;gap:${Math.round(h * .18)}px;height:100%;padding:0 ${Math.round(h * .25)}px">${mk(Math.round(h * .55))}<div style="flex:1;min-width:0"><div class="h" style="font-size:${fs}px;white-space:nowrap;overflow:hidden">${a.t}</div>${w >= 700 ? `<div style="font-size:${Math.round(h * .2)}px;margin-top:3px">${a.s}</div>` : ''}</div><span class="btn" style="font-size:${Math.round(h * .22)}px;padding:${Math.round(h * .12)}px ${Math.round(h * .2)}px">${a.cta}</span></div>`, cls === 'ink' ? 'ink' : '');
}
if (w <= 160) { // tile + tower
const tall = h > w * 2;
return page(w, h, `<div style="display:flex;flex-direction:column;align-items:center;justify-content:${tall ? 'space-between' : 'center'};height:100%;padding:${tall ? 24 : 8}px 8px;text-align:center;gap:6px">${mk(tall ? 54 : 34)}<div class="h" style="font-size:${tall ? 30 : 15}px">${a.t}</div>${tall ? `<div style="font-size:16px">${a.s}</div>` : ''}<div class="wm" style="font-size:${tall ? 18 : 11}px">ViralAd<b>Source</b></div>${tall ? `<span class="btn" style="font-size:15px;padding:10px 12px">${a.cta}</span>` : ''}</div>`, cls === 'ink' ? 'ink' : '');
}
if (shape === 'small') return page(w, h, `<div style="display:flex;flex-direction:column;justify-content:space-between;height:100%;padding:18px">
<div class="wm" style="font-size:17px;display:flex;align-items:center;gap:6px">${mk(24)}<span>ViralAd<b>Source</b></span></div>
<div class="h" style="font-size:38px">${a.t}</div><div><span class="btn" style="font-size:15px;padding:9px 14px">${a.cta}</span></div></div>`, cls === 'ink' ? 'ink' : '');
if (shape === 'wide') return page(w, h, `<div style="display:flex;flex-direction:column;justify-content:space-between;height:100%;padding:26px 30px;max-width:${cls === 'ink' ? w : 390}px">
<div class="wm" style="font-size:20px;display:flex;align-items:center;gap:8px">${mk(28)}<span>ViralAd<b>Source</b></span></div>
<div><div class="m" style="font-size:12px;color:${cls === 'ink' ? '#FF9479' : '#0B5A57'};margin-bottom:6px">${a.k}</div><div class="h" style="font-size:44px">${a.t}</div><div style="font-size:16px;margin-top:8px">${a.s}</div></div>
<div><span class="btn" style="font-size:16px;padding:9px 18px">${a.cta}</span></div></div>`, cls);
const big = Math.min(w, h); const pad = Math.round(big * .07);
return page(w, h, `<div style="display:flex;flex-direction:column;justify-content:space-between;height:100%;padding:${pad}px;max-width:${w > h * 1.4 ? Math.round(w * .62) : w}px">
<div class="wm" style="font-size:${Math.round(big * .065)}px;display:flex;align-items:center;gap:8px">${mk(Math.round(big * .09))}<span>ViralAd<b>Source</b></span></div>
<div><div class="m" style="font-size:${Math.round(big * .04)}px;color:${cls === 'ink' ? '#FF9479' : '#0B5A57'};margin-bottom:${Math.round(big * .02)}px">${a.k}</div><div class="h" style="font-size:${Math.round(big * .13)}px">${a.t}</div><div style="font-size:${Math.round(big * .052)}px;margin-top:${Math.round(big * .03)}px">${a.s}</div></div>
<div><span class="btn" style="font-size:${Math.round(big * .05)}px;padding:${Math.round(big * .028)}px ${Math.round(big * .05)}px">${a.cta}</span></div></div>`, cls);
}
const shots = [
['icon-192.png', 192, 192, page(192, 192, `<div style="display:flex;align-items:center;justify-content:center;height:100%;background:#EAF6F4;border-radius:36px">${MARK(150)}</div>`)],
['og-share.png', 1200, 630, kit('free', 'social')],
['proof/vas-proof-river.png', 1200, 630, page(1200, 630, `<div style="display:flex;flex-direction:column;justify-content:space-between;height:100%;padding:60px;max-width:760px"><div class="wm" style="font-size:40px;display:flex;align-items:center;gap:10px">${MARK(54)}<span>ViralAd<b>Source</b></span></div><div><div class="m" style="font-size:22px;color:#0B5A57">Paid on chain</div><div class="h" style="font-size:84px">A Boost flowed back to the branch that sold it.</div></div><div style="font-size:24px">Resharer, sponsor line, reward pot: one transaction. Verify it on Polygonscan.</div></div>`, 'river')],
['proof/vas-proof-ink.png', 1200, 630, page(1200, 630, `<div style="display:flex;flex-direction:column;justify-content:space-between;height:100%;padding:60px"><div class="wm" style="font-size:40px;display:flex;align-items:center;gap:10px">${MARKL(54)}<span>ViralAd<b>Source</b></span></div><div><div class="m" style="font-size:22px;color:#FF9479">Live ledger</div><div class="h" style="font-size:90px">Every ad has a source.<br>Every payment has a proof.</div></div><div style="font-size:24px;color:#B9DCD7">Results are rewarded, never a bare share.</div></div>`, 'ink')]
];
const ONLY = (process.env.ONLY || '').split(',').filter(Boolean); // render just these kit shapes
if (ONLY.length) shots.length = 0;
for (const angle of Object.keys(ANG)) for (const shape of Object.keys(SHAPES)) { if (ONLY.length && !ONLY.includes(shape)) continue; const [w, h] = SHAPES[shape]; shots.push(['kit/vas-' + angle + '-' + shape + '.png', w, h, kit(angle, shape)]); }
const browser = await chromium.launch();
const pg = await browser.newPage();
for (const [file, w, h, html] of shots) {
await pg.setViewportSize({ width: w, height: h }); await pg.setContent(html, { waitUntil: 'networkidle' });
await pg.screenshot({ path: path.join(ART, file), clip: { x: 0, y: 0, width: w, height: h } });
}
await browser.close();
console.log('art written:', shots.length);