shots: app titles get the weights the templates use (variable axis, used range or static weights; font-weight warning), palette.bg as one colour or a CSS gradient string (validated; contrast guard in shots check), photo backgrounds (palette.image, shots.feature.background) with overlay and cover crop
This commit is contained in:
parent
2ba8278ab7
commit
3a11682a37
21 changed files with 713 additions and 44 deletions
|
|
@ -95,12 +95,14 @@ const R = document.documentElement.style;
|
|||
// #rrggbb -> rgba with alpha, for the soft accent glow
|
||||
const rgba = (hex, a) => { const m = /^#?([0-9a-f]{6})$/i.exec(hex); if (!m) return hex; const n = parseInt(m[1], 16); return `rgba(${n >> 16},${(n >> 8) & 255},${n & 255},${a})`; };
|
||||
const lum = hex => { const m = /^#?([0-9a-f]{6})$/i.exec(hex); if (!m) return 1; const n = parseInt(m[1], 16); return (.299 * (n >> 16) + .587 * ((n >> 8) & 255) + .114 * (n & 255)) / 255; };
|
||||
const dark = lum(P.bg[1]) < .45;
|
||||
const tone = P.bgTone ?? (Array.isArray(P.bg) ? P.bg[1] : P.bg);
|
||||
const dark = !!P.photo && P.photo.overlay >= .35 || lum(tone) < .45;
|
||||
R.setProperty('--W', W + 'px'); R.setProperty('--H', H + 'px'); R.setProperty('--u', u + 'px');
|
||||
R.setProperty('--ink', P.ink); R.setProperty('--accent', P.glow); R.setProperty('--shadow', P.shadow);
|
||||
R.setProperty('--line2', dark ? P.glow : P.ink);
|
||||
R.setProperty('--accentSoft', rgba(P.glow, dark ? .28 : .14));
|
||||
R.setProperty('--bg', P.bg[0] === P.bg[2] && P.bg[1] === P.bg[0] ? P.bg[0] : `linear-gradient(180deg, ${P.bg[0]} 0%, ${P.bg[1]} 55%, ${P.bg[2]} 100%)`);
|
||||
// bgCss from job.json (palette.ts bgCss / photoCss): stops, one colour, a CSS gradient string, or a photo under an overlay
|
||||
R.setProperty('--bg', P.bgCss ?? (Array.isArray(P.bg) ? `linear-gradient(180deg, ${P.bg.join(', ')})` : P.bg));
|
||||
const T = job.fonts.title, B = job.fonts.body, X = job.fonts.script;
|
||||
// titleStack / bodyStack (from shots fonts): script face, the configured font, then any automatic Noto fallback
|
||||
const fstack = (st, def) => (st ?? (X ? [X, def] : [def])).map(f => `'${f}'`).join(', ') + ', sans-serif';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue