Kit de carteles, recursos y publicaciones de octubre

This commit is contained in:
pnh 2026-10-17 11:48:50 +02:00
parent 4d4741c1fc
commit 118d577d22
No known key found for this signature in database
19 changed files with 740 additions and 0 deletions

View file

@ -0,0 +1,109 @@
import fs from 'fs';
import { chromium } from 'playwright-core';
const D = process.cwd();
const b64 = f => fs.readFileSync(D + '/' + f).toString('base64');
const font = f => fs.readFileSync(D + '/node_modules/@fontsource/' + f).toString('base64');
function raggedBar(x0, y0, x1, y1, w) {
const dx = x1 - x0, dy = y1 - y0, L = Math.hypot(dx, dy), ux = dx / L, uy = dy / L, nx = -uy, ny = ux;
const pts = [], n = 9;
for (let s = 0; s <= 1; s++) {
const side = s ? -1 : 1, seq = [];
for (let k = 0; k <= n; k++) {
const t = k / n * L, knot = (k > 0 && k < n && k % 2 === 1) ? 26 : 0;
seq.push([x0 + ux * t + nx * side * (w / 2 + knot), y0 + uy * t + ny * side * (w / 2 + knot)]);
if (knot) seq.push([x0 + ux * (t + 18) + nx * side * w / 2, y0 + uy * (t + 18) + ny * side * w / 2]);
}
pts.push(...(s ? seq.reverse() : seq));
}
return 'M' + pts.map(p => p.map(v => v.toFixed(1)).join(',')).join('L') + 'Z';
}
const cross = raggedBar(-60, -60, 1140, 1140, 110) + raggedBar(1140, -60, -60, 1140, 110);
// anchor + laurel, centred at (cx, cy)
function emblem(cx, cy) {
const g = '#F2C64B';
let leaves = '';
for (const side of [-1, 1]) {
// branch: arc from bottom centre outwards and up
const pts = [];
for (let i = 0; i <= 10; i++) {
const t = i / 10, a = Math.PI * (0.62 + 0.62 * t);
pts.push([cx + side * -Math.cos(a) * 92 * -1, cy + 18 - Math.sin(a) * 82]);
}
leaves += `<path d="M${pts.map(p => p.map(v => v.toFixed(1)).join(',')).join('L')}" fill="none" stroke="${g}" stroke-width="2.5"/>`;
for (let i = 1; i < 10; i++) {
const [x, y] = pts[i], [x2, y2] = pts[i + 1];
const ang = Math.atan2(y2 - y, x2 - x) * 180 / Math.PI;
leaves += `<ellipse cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" rx="11" ry="4.6" fill="${g}" transform="rotate(${(ang - side * 38).toFixed(1)} ${x.toFixed(1)} ${y.toFixed(1)}) translate(${side * -2} -6)"/>`;
leaves += `<ellipse cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" rx="11" ry="4.6" fill="#D9A63A" transform="rotate(${(ang + side * 38).toFixed(1)} ${x.toFixed(1)} ${y.toFixed(1)}) translate(${side * 2} 6)"/>`;
}
}
const anchor = `
<circle cx="${cx}" cy="${cy - 70}" r="13" fill="none" stroke="${g}" stroke-width="6"/>
<rect x="${cx - 52}" y="${cy - 54}" width="104" height="10" rx="5" fill="${g}"/>
<circle cx="${cx - 54}" cy="${cy - 49}" r="7" fill="${g}"/><circle cx="${cx + 54}" cy="${cy - 49}" r="7" fill="${g}"/>
<rect x="${cx - 5.5}" y="${cy - 58}" width="11" height="128" fill="${g}"/>
<path d="M${cx - 66},${cy + 22} Q${cx - 60},${cy + 76} ${cx},${cy + 80} Q${cx + 60},${cy + 76} ${cx + 66},${cy + 22}" fill="none" stroke="${g}" stroke-width="10" stroke-linecap="round"/>
<path d="M${cx - 66},${cy + 6} l-14,26 l26,-6 z M${cx + 66},${cy + 6} l14,26 l-26,-6 z" fill="${g}"/>
<path d="M${cx},${cy + 70} l-12,16 l12,8 l12,-8 z" fill="${g}"/>`;
return `<g filter="url(#sh)">${leaves}${anchor}</g>`;
}
const ships = ['SANTÍSIMA TRINIDAD', 'PRÍNCIPE DE ASTURIAS', 'SANTA ANA', 'RAYO', 'NEPTUNO', 'ARGONAUTA', 'SAN ILDEFONSO', 'BAHAMA',
'SAN JUAN NEPOMUCENO', 'SAN AGUSTÍN', 'MONARCA', 'MONTAÑÉS', 'SAN FRANCISCO DE ASÍS', 'SAN JUSTO', 'SAN LEANDRO'];
const svg = `<svg width="1080" height="1080" viewBox="0 0 1080 1080" xmlns="http://www.w3.org/2000/svg" style="position:absolute;inset:0">
<defs>
<radialGradient id="bg" cx="50%" cy="55%" r="75%"><stop offset="0" stop-color="#6a0a14"/><stop offset=".55" stop-color="#4B0000"/><stop offset="1" stop-color="#220306"/></radialGradient>
<linearGradient id="gold" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FFE9A6"/><stop offset=".45" stop-color="#F2C64B"/><stop offset="1" stop-color="#C9962C"/></linearGradient>
<radialGradient id="halo"><stop offset="0" stop-color="#F2C64B" stop-opacity=".30"/><stop offset="1" stop-color="#F2C64B" stop-opacity="0"/></radialGradient>
<linearGradient id="plaque" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#2a0508"/><stop offset="1" stop-color="#1a0204"/></linearGradient>
<filter id="sh" x="-20%" y="-20%" width="140%" height="140%"><feDropShadow dx="0" dy="4" stdDeviation="5" flood-color="#000" flood-opacity=".55"/></filter>
<clipPath id="inner"><rect x="44" y="44" width="992" height="992"/></clipPath>
</defs>
<rect width="1080" height="1080" fill="url(#bg)"/>
<g clip-path="url(#inner)"><path d="${cross}" fill="#A10F2B" opacity=".18"/></g>
<circle cx="540" cy="462" r="120" fill="url(#halo)"/>
<g transform="translate(540,462) scale(.8) translate(-540,-470)">${emblem(540, 470)}</g>
<!-- plaque -->
<rect x="112" y="552" width="856" height="396" fill="url(#plaque)" opacity=".85" stroke="#D9A63A" stroke-width="2.5" filter="url(#sh)"/>
<rect x="124" y="564" width="832" height="372" fill="none" stroke="#D9A63A" stroke-width="1"/>
${[[124, 564], [956, 564], [124, 936], [956, 936]].map(([x, y]) => `<circle cx="${x}" cy="${y}" r="5" fill="#D9A63A"/>`).join('')}
<rect x="26" y="26" width="1028" height="1028" fill="none" stroke="#D9A63A" stroke-width="4"/>
<rect x="38" y="38" width="1004" height="1004" fill="none" stroke="#D9A63A" stroke-width="1.5"/>
<g font-family="Cinzel" font-weight="700" font-size="27" fill="url(#gold)" letter-spacing="3">
<text x="460" y="104" text-anchor="end">PARTIDO NACIONAL</text>
<text x="620" y="104" text-anchor="start">HISPANISTA</text>
</g>
<image href="data:image/png;base64,${b64('horse.png')}" x="483" y="62" width="114" height="72"/>
<line x1="90" y1="148" x2="990" y2="148" stroke="#D9A63A" stroke-width="1.5"/>
<line x1="90" y1="154" x2="990" y2="154" stroke="#D9A63A" stroke-width="1"/>
<text x="540" y="210" text-anchor="middle" font-family="Cinzel" font-weight="700" font-size="32" fill="url(#gold)" letter-spacing="8">— 21 DE OCTUBRE DE 1805 —</text>
<text x="540" y="318" text-anchor="middle" font-family="Cinzel" font-weight="900" font-size="120" fill="#FBF3E4" letter-spacing="3" filter="url(#sh)">TRAFALGAR</text>
<text x="540" y="368" text-anchor="middle" font-family="Garamond" font-style="italic" font-size="36" fill="#F2C64B">A los marinos de España</text>
<line x1="90" y1="968" x2="990" y2="968" stroke="#D9A63A" stroke-width="1"/>
<text x="540" y="1008" text-anchor="middle" font-family="Cinzel" font-weight="700" font-size="22" fill="#D9A63A" letter-spacing="5">GRAVINA · CHURRUCA · ALCALÁ GALIANO</text>
</svg>`;
const html = `<!doctype html><html><head><meta charset="utf-8"><style>
@font-face{font-family:Cinzel;font-weight:700;src:url(data:font/woff2;base64,${font('cinzel/files/cinzel-latin-700-normal.woff2')})}
@font-face{font-family:Cinzel;font-weight:900;src:url(data:font/woff2;base64,${font('cinzel/files/cinzel-latin-900-normal.woff2')})}
@font-face{font-family:Garamond;font-style:italic;font-weight:500;src:url(data:font/woff2;base64,${font('eb-garamond/files/eb-garamond-latin-500-italic.woff2')})}
html,body{margin:0;background:#2a0508}
.s{position:relative;width:1080px;height:1080px;overflow:hidden}
.pl{position:absolute;left:124px;width:832px;top:564px;height:372px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px}
.ph{font-family:Cinzel;font-weight:700;font-size:19px;letter-spacing:7px;color:#D9A63A}
.grid{display:grid;grid-template-columns:1fr 1fr;column-gap:56px;row-gap:6px;font-family:Cinzel;font-weight:700;font-size:21px;letter-spacing:2px;color:#F2C64B;text-shadow:0 1px 0 #000,0 -1px 0 rgba(255,233,166,.25)}
.grid div:nth-child(odd){text-align:right}
.grid div.last{grid-column:1 / span 2;text-align:center}
.orn{color:#D9A63A;font-size:18px;letter-spacing:10px}
</style></head><body><div class="s">${svg}
<div class="pl"><div class="ph">NAVÍOS DE LA REAL ARMADA</div><div class="orn">✦ ✦ ✦</div>
<div class="grid">${ships.map((n, i) => `<div${i === 14 ? ' class="last"' : ''}>${n}</div>`).join('')}</div></div>
</div></body></html>`;
const browser = await chromium.launch({ executablePath: '/opt/pw-browsers/chromium' });
const pg = await browser.newPage({ viewport: { width: 1080, height: 1080 } });
await pg.setContent(html); await pg.evaluate(() => document.fonts.ready); await pg.waitForTimeout(200);
await pg.screenshot({ path: D + '/lapida.png', clip: { x: 0, y: 0, width: 1080, height: 1080 } });
await browser.close(); console.log('ok');