Screenshot pipeline groundwork: capture source config, device builders, store specs, checks, variants, video builders
Salvaged from wip/shots-pipeline. Pure modules (spec, devices, report, video, check), variant support in render / lib, 13" iPad size and 3:4 template layout. Not all of it is wired into the CLI yet.
This commit is contained in:
parent
9be0556685
commit
bd89eb748a
12 changed files with 1141 additions and 73 deletions
|
|
@ -5,7 +5,7 @@
|
|||
<link rel="stylesheet" href="/fonts/fonts.css">
|
||||
<!--
|
||||
Store screenshot template (rendered by `storebound shots render`, served by its local server).
|
||||
template.html?s=<scene id>&w=<px>&h=<px>&lang=<id>[&device=tablet]
|
||||
template.html?s=<scene id>&w=<px>&h=<px>&lang=<id>[&device=tablet][&v=<variant>]
|
||||
/job.json gives the scene (palette, frames, badge slots), the words for this language and the font families.
|
||||
Layout: everything is in u = W / 100; the text block is measured first, then the phone fills the room below it.
|
||||
-->
|
||||
|
|
@ -103,9 +103,9 @@
|
|||
<div id="c"></div>
|
||||
<script type="module">
|
||||
const q = new URLSearchParams(location.search);
|
||||
const W = +q.get('w'), H = +q.get('h'), LANG = q.get('lang'), SID = q.get('s');
|
||||
const W = +q.get('w'), H = +q.get('h'), LANG = q.get('lang'), SID = q.get('s'), V = q.get('v') ?? '';
|
||||
const tablet = q.get('device') === 'tablet';
|
||||
const job = await (await fetch(`/job.json?lang=${encodeURIComponent(LANG)}&s=${encodeURIComponent(SID)}`)).json();
|
||||
const job = await (await fetch(`/job.json?lang=${encodeURIComponent(LANG)}&s=${encodeURIComponent(SID)}&v=${encodeURIComponent(V)}`)).json();
|
||||
const S = job.scene, C = job.copy, P = job.palette;
|
||||
const u = W / 100, Hu = H / u;
|
||||
const dev = tablet ? job.tablet : job.phone; // { w, h, bar } in CSS px of the raw frame
|
||||
|
|
@ -131,9 +131,10 @@ if (LANG.startsWith('ja')) document.documentElement.style.wordBreak = 'auto-phra
|
|||
if (LANG.startsWith('ko')) document.documentElement.style.wordBreak = 'keep-all';
|
||||
if (tablet) document.body.classList.add('tablet');
|
||||
const tall = Hu > 200; // iOS 6.9" / 6.5" vs 16:9
|
||||
R.setProperty('--top', tall ? 9 : 5.5);
|
||||
R.setProperty('--fs', S.hero ? (tall ? 10.5 : 8.6) : (tall ? 12 : 9.8));
|
||||
R.setProperty('--sub', tall ? 3.75 : 3.3);
|
||||
const wide = Hu < 150; // 3:4 iPad
|
||||
R.setProperty('--top', tall ? 9 : wide ? 4 : 5.5);
|
||||
R.setProperty('--fs', S.hero ? (tall ? 10.5 : wide ? 7 : 8.6) : (tall ? 12 : wide ? 7.6 : 9.8));
|
||||
R.setProperty('--sub', tall ? 3.75 : wide ? 2.7 : 3.3);
|
||||
const AR = dev.w / (dev.h + dev.bar);
|
||||
R.setProperty('--ar', `${dev.w} / ${dev.h + dev.bar}`);
|
||||
R.setProperty('--appH', `${100 * dev.h / (dev.h + dev.bar)}%`);
|
||||
|
|
@ -176,11 +177,18 @@ c.innerHTML = `<div class="glow"></div><div class="rays"></div><div class="vign"
|
|||
|
||||
await document.fonts.ready;
|
||||
await Promise.all([...document.images].map(i => i.decode().catch(() => {})));
|
||||
for (const sp of c.querySelectorAll('h1 span')) { // shrink a line that would overflow (long words)
|
||||
const overflow = []; // read by `shots render` -> report.json -> shots check / gallery
|
||||
for (const [i, sp] of [...c.querySelectorAll('h1 span')].entries()) { // shrink a line that would overflow (long words)
|
||||
const max = W - 10 * u, wd = sp.getBoundingClientRect().width;
|
||||
let f = 1; while (wd * f > max && f > .55) f -= .02;
|
||||
if (f < 1) sp.style.fontSize = `calc(${getComputedStyle(sp).fontSize} * ${f.toFixed(2)})`;
|
||||
if (wd * f > max + 1) overflow.push(`title line ${i + 1} is too long even at 55 % size: shorten it`);
|
||||
else if (f < .7) overflow.push(`title line ${i + 1} shrunk to ${Math.round(f * 100)} %: consider shorter words`);
|
||||
}
|
||||
const subEl = c.querySelector('p.sub');
|
||||
if (subEl) { const lines = Math.round(subEl.getBoundingClientRect().height / parseFloat(getComputedStyle(subEl).lineHeight)); if (lines > 3) overflow.push(`subtitle wraps to ${lines} lines (max 3)`); }
|
||||
const eb = c.querySelector('.eyebrow');
|
||||
if (eb && eb.getBoundingClientRect().width > W - 8 * u) overflow.push('eyebrow is wider than the image');
|
||||
const textBottom = c.querySelector('.top').getBoundingClientRect().bottom / u;
|
||||
|
||||
const frames = S.frames.map(f => ({ x: 0, dy: 0, scale: 1, rotate: 0, ...f }));
|
||||
|
|
@ -225,6 +233,9 @@ html += phone(front, 'front');
|
|||
});
|
||||
c.insertAdjacentHTML('beforeend', html);
|
||||
await Promise.all([...document.images].map(i => i.decode().catch(() => {})));
|
||||
if (textBottom > Hu * .48) overflow.push(`text block covers ${Math.round(textBottom / Hu * 100)} % of the height (the game should be the star)`);
|
||||
for (const b of c.querySelectorAll('.badge')) { const r = b.getBoundingClientRect(); if (r.left < 0 || r.right > W || r.bottom > H) overflow.push(`badge "${b.textContent.trim().slice(0, 30)}" runs off the image`); }
|
||||
document.body.dataset.overflow = JSON.stringify(overflow);
|
||||
document.body.dataset.ready = '1';
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue