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,161 @@
import fs from 'fs';
import { geoMercator, geoPath } from 'd3-geo';
import { feature } from 'topojson-client';
import { chromium } from 'playwright-core';
const D = process.cwd();
const topo = JSON.parse(fs.readFileSync(D + '/node_modules/world-atlas/countries-50m.json'));
const countries = feature(topo, topo.objects.countries).features;
const b64 = f => fs.readFileSync(D + '/' + f).toString('base64');
const font = f => fs.readFileSync(D + '/node_modules/@fontsource/' + f).toString('base64');
const HISP = new Set([724, 620, 484, 320, 340, 222, 558, 188, 591, 192, 214, 630, 170, 862, 218, 604, 68, 152, 32, 858, 600, 76, 226].map(String).map(s => s.padStart(3, '0')));
const PHI = '608';
// main map: Americas
const W = 1080;
const proj = geoMercator().fitExtent([[80, 470], [640, 975]], {
type: 'MultiPoint', coordinates: [[-117, 32.5], [-60, 23], [-74, -55.5], [-34.8, -10]]
});
const path = geoPath(proj);
const iproj = geoMercator().fitExtent([[760, 455], [990, 645]], { type: 'MultiPoint', coordinates: [[-9.5, 36], [4.3, 43.8]] });
const ipath = geoPath(iproj);
const IBE = new Set(['724', '620']);
let canar = '';
const cproj = geoMercator().scale(iproj.scale()).center([-15.6, 28.3]).translate([742, 668]);
let hisp = '', iber = '';
for (const c of countries) {
if (c.id === PHI) continue;
if (IBE.has(c.id)) {
if (c.id === '724') {
const polys = c.geometry.coordinates;
const main = polys.filter(p => p[0].every(([x]) => x > -12));
const can = polys.filter(p => p[0].some(([x]) => x <= -12) && p[0].every(([, y]) => y > 26.5));
iber += ipath({ type: 'MultiPolygon', coordinates: main });
canar = geoPath(cproj)({ type: 'MultiPolygon', coordinates: can });
} else iber += ipath(c);
continue;
}
if (!HISP.has(c.id)) continue;
const d = path(c); if (!d) continue;
const [[x0, y0], [x1, y1]] = path.bounds(c);
if (x1 < 0 || x0 > W || y1 < 0 || y0 > W) continue;
hisp += d;
}
hisp += iber + canar;
const phi = countries.find(c => c.id === PHI);
const pproj = geoMercator().fitExtent([[905, 700], [1000, 880]], phi);
const phiPath = geoPath(pproj)(phi);
const P = iproj([-6.9, 37.2]), G = cproj([-17.2, 28.1]), S = proj([-74.5, 24.1]);
const route = `M${P[0]},${P[1]} Q${(P[0] + G[0]) / 2 + 10},${(P[1] + G[1]) / 2 + 5} ${G[0]},${G[1]} Q${(G[0] + S[0]) / 2},${Math.min(G[1], S[1]) - 70} ${S[0]},${S[1]}`;
const mid = [(G[0] + S[0]) / 2 + 10, (G[1] + S[1]) / 2 - 50];
// sun centre in mid-Atlantic
const sun = [645, 650];
let rays = '';
for (let i = 0; i < 36; i++) {
const a = i * Math.PI * 2 / 36, r0 = 70, r1 = i % 2 ? 190 : 270;
rays += `<line x1="${sun[0] + r0 * Math.cos(a)}" y1="${sun[1] + r0 * Math.sin(a)}" x2="${sun[0] + r1 * Math.cos(a)}" y2="${sun[1] + r1 * Math.sin(a)}"/>`;
}
// ragged Cross of Burgundy (background, faint)
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);
const caravel = `<g transform="translate(${mid[0]},${mid[1]}) scale(0.95)">
<path d="M-34,6 L34,6 L26,18 L-26,18 Z" fill="#E8C36A"/>
<path d="M-36,6 L-28,-2 L-22,6Z" fill="#E8C36A"/>
<line x1="-12" y1="6" x2="-12" y2="-34" stroke="#E8C36A" stroke-width="2.4"/>
<line x1="10" y1="6" x2="10" y2="-40" stroke="#E8C36A" stroke-width="2.4"/>
<line x1="26" y1="6" x2="26" y2="-22" stroke="#E8C36A" stroke-width="2"/>
<path d="M-24,-30 Q-12,-26 0,-30 L0,-4 Q-12,0 -24,-4 Z" fill="#FBF3E4"/>
<path d="M-2,-37 Q10,-33 22,-37 L22,-6 Q10,-2 -2,-6 Z" fill="#FBF3E4"/>
<path d="M26,-22 L38,-4 L26,-4 Z" fill="#FBF3E4"/>
<path d="M8,-26 h4 v-4 h4 v4 h4 v4 h-4 v4 h-4 v-4 h-4z" transform="translate(-4,6)" fill="#A10F2B"/>
<path d="M8,-26 h4 v-4 h4 v4 h4 v4 h-4 v4 h-4 v-4 h-4z" transform="translate(-26,10)" fill="#A10F2B"/>
</g>`;
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')})}
@font-face{font-family:Garamond;font-weight:600;src:url(data:font/woff2;base64,${font('eb-garamond/files/eb-garamond-latin-600-normal.woff2')})}
html,body{margin:0;background:#2a0508}
</style></head><body>
<svg width="1080" height="1080" viewBox="0 0 1080 1080" xmlns="http://www.w3.org/2000/svg">
<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>
<linearGradient id="goldMap" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#F6D27A"/><stop offset="1" stop-color="#D9A63A"/></linearGradient>
<radialGradient id="sunG"><stop offset="0" stop-color="#FFE7A0" stop-opacity=".95"/><stop offset=".55" stop-color="#F2C64B" stop-opacity=".55"/><stop offset="1" stop-color="#F2C64B" stop-opacity="0"/></radialGradient>
<filter id="sh" x="-20%" y="-20%" width="140%" height="140%"><feDropShadow dx="0" dy="4" stdDeviation="6" flood-color="#000" flood-opacity=".55"/></filter>
<filter id="glow"><feGaussianBlur stdDeviation="18"/></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=".22"/>
<circle cx="${sun[0]}" cy="${sun[1]}" r="120" fill="url(#sunG)" opacity=".35"/>
<g stroke="#F2C64B" stroke-width="2.2" opacity=".35">${rays}</g>
<path d="${hisp}" fill="url(#goldMap)" stroke="#8B0000" stroke-width=".7" filter="url(#sh)"/>
<path d="${phiPath}" fill="url(#goldMap)" stroke="#8B0000" stroke-width=".6" filter="url(#sh)"/>
<path d="${route}" fill="none" stroke="#FBF3E4" stroke-width="2.6" stroke-dasharray="2 9" stroke-linecap="round" opacity=".9"/>
<circle cx="${P[0]}" cy="${P[1]}" r="5" fill="#FBF3E4"/><circle cx="${S[0]}" cy="${S[1]}" r="5" fill="#FBF3E4"/>
<text x="${S[0] - 70}" y="${S[1] - 12}" font-family="Cinzel" font-weight="700" font-size="17" fill="#FBF3E4" letter-spacing="2">1492</text>
${caravel}
</g>
<!-- Pilar -->
<ellipse cx="160" cy="790" rx="110" ry="150" fill="#F2C64B" opacity=".22" filter="url(#glow)"/>
<image href="data:image/png;base64,${b64('pilar.png')}" x="94" y="640" width="132" height="334" filter="url(#sh)"/>
<text x="160" y="1000" text-anchor="middle" font-family="Garamond" font-style="italic" font-size="17" fill="#F2C64B">N.ª S.ª del Pilar</text>
<!-- emblem -->
<image href="data:image/png;base64,${b64('logo_full_hd.png')}" x="575" y="752" width="330" height="219" filter="url(#sh)"/>
<!-- frame -->
<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"/>
<!-- header (2024 banner) -->
<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"/>
<!-- titles -->
<text x="540" y="222" text-anchor="middle" font-family="Cinzel" font-weight="700" font-size="50" fill="url(#gold)" letter-spacing="6">— 12 DE OCTUBRE —</text>
<text x="540" y="345" text-anchor="middle" font-family="Cinzel" font-weight="900" font-size="122" fill="#FBF3E4" letter-spacing="2" filter="url(#sh)">HISPANIDAD</text>
<g font-family="Garamond" font-style="italic" font-size="40" fill="#F2C64B">
<text x="540" y="408" text-anchor="middle">Unidad, Fe y Destino</text>
</g>
<g stroke="#D9A63A" stroke-width="1.5"><line x1="215" y1="396" x2="355" y2="396"/><line x1="725" y1="396" x2="865" y2="396"/></g>
<g fill="#D9A63A"><path d="M360,396 l7,-6 l7,6 l-7,6z"/><path d="M706,396 l7,-6 l7,6 l-7,6z"/></g>
<!-- footer -->
<text x="540" y="1012" text-anchor="middle" font-family="Cinzel" font-weight="700" font-size="25" fill="url(#gold)" letter-spacing="4">¡ARRIBA LA HISPANIDAD! · 2026</text>
</svg></body></html>`;
fs.writeFileSync(D + '/poster.html', html);
const browser = await chromium.launch({ executablePath: '/opt/pw-browsers/chromium' + (fs.existsSync('/opt/pw-browsers/chromium') && fs.statSync('/opt/pw-browsers/chromium').isDirectory() ? '/chrome' : '') });
const pg = await browser.newPage({ viewport: { width: 1080, height: 1080 }, deviceScaleFactor: 2 });
await pg.setContent(html); await pg.evaluate(() => document.fonts.ready); await pg.waitForTimeout(300);
await pg.screenshot({ path: D + '/out.png', clip: { x: 0, y: 0, width: 1080, height: 1080 } });
await browser.close();
console.log('ok', P, G, S, sun);

View file

@ -0,0 +1,111 @@
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="790" r="200" fill="url(#halo)"/>
<g transform="translate(540,800) scale(.78) translate(-540,-470)">${emblem(540, 470)}</g>
<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="320" text-anchor="middle" font-family="Cinzel" font-weight="900" font-size="124" fill="#FBF3E4" letter-spacing="3" filter="url(#sh)">TRAFALGAR</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">HONOR Y GLORIA A LOS MARINOS DE ESPAÑA</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')})}
@font-face{font-family:Garamond;font-style:italic;font-weight:600;src:url(data:font/woff2;base64,${font('eb-garamond/files/eb-garamond-latin-600-italic.woff2')})}
html,body{margin:0;background:#2a0508}
.s{position:relative;width:1080px;height:1080px;overflow:hidden}
.q{position:absolute;left:110px;right:110px;top:372px;text-align:center;font-family:Garamond;font-style:italic;font-weight:500;font-size:54px;line-height:1.18;color:#FBF3E4;text-wrap:balance;text-shadow:0 3px 10px rgba(0,0,0,.45)}
.q b{font-weight:600;color:#F2C64B}
.att{position:absolute;left:0;right:0;top:545px;text-align:center}
.att .n{font-family:Cinzel;font-weight:900;font-size:40px;letter-spacing:4px;color:#F2C64B}
.att .r{font-family:Garamond;font-style:italic;font-size:26px;color:#FBF3E4;margin-top:8px;opacity:.9}
.att .r2{font-family:Cinzel;font-weight:700;font-size:17px;letter-spacing:5px;color:#D9A63A;margin-top:12px}
.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="q">«Si llegas a saber que mi navío ha sido hecho prisionero, <b>dame por muerto.</b>»</div>
<div class="att"><div class="n">COSME DAMIÁN CHURRUCA</div><div class="r">Brigadier de la Real Armada · Comandante del <i>San Juan Nepomuceno</i></div><div class="r2">Cayó en combate en Trafalgar</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 + '/churruca.png', clip: { x: 0, y: 0, width: 1080, height: 1080 } });
await browser.close(); console.log('ok');

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');

View file

@ -0,0 +1,166 @@
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');
const OUT = process.argv[2] || D + '/carrusel';
fs.mkdirSync(OUT, { recursive: true });
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);
const horse = b64('horse.png'), logo = b64('logo_full_hd.png');
const TOTAL = 6;
const css = `
@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-weight:500;src:url(data:font/woff2;base64,${font('eb-garamond/files/eb-garamond-latin-500-normal.woff2')})}
@font-face{font-family:Garamond;font-weight:600;src:url(data:font/woff2;base64,${font('eb-garamond/files/eb-garamond-latin-600-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;color:#FBF3E4}
.s>svg{position:absolute;inset:0}
.txt{position:absolute;left:96px;right:96px;top:215px;bottom:150px;display:flex;flex-direction:column;justify-content:center;gap:34px}
.kick{font-family:Cinzel;font-weight:700;font-size:24px;letter-spacing:6px;color:#D9A63A}
h1{margin:0;font-family:Cinzel;font-weight:900;font-size:68px;line-height:1.05;color:#F2C64B;text-wrap:balance}
p{margin:0;font-family:Garamond;font-weight:500;font-size:37px;line-height:1.32;color:#FBF3E4}
p b{font-weight:600;color:#F2C64B}
.rows{display:flex;flex-direction:column;gap:22px}
.row{display:grid;grid-template-columns:270px 1fr;gap:28px;align-items:baseline;border-top:1.5px solid rgba(217,166,58,.55);padding-top:20px}
.row .k{font-family:Cinzel;font-weight:900;font-size:34px;color:#F2C64B;letter-spacing:1px}
.row .v{font-family:Garamond;font-weight:500;font-size:33px;line-height:1.28}
.row.hl .k{color:#FBF3E4;background:#A10F2B;padding:2px 12px;justify-self:start;white-space:nowrap;font-size:30px}
.quote{font-family:Garamond;font-style:italic;font-size:44px;line-height:1.25;color:#F2C64B;border-left:4px solid #D9A63A;padding-left:28px}
`;
function frame(n) {
return `<svg width="1080" height="1080" viewBox="0 0 1080 1080" xmlns="http://www.w3.org/2000/svg">
<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>
<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="${n === 1 ? .22 : .13}"/></g>
<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,${horse}" 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"/>
<line x1="90" y1="968" x2="990" y2="968" stroke="#D9A63A" stroke-width="1"/>
<text x="96" y="1008" font-family="Cinzel" font-weight="700" font-size="20" fill="#D9A63A" letter-spacing="4">29N · VOTO EN BLANCO</text>
<text x="984" y="1008" text-anchor="end" font-family="Cinzel" font-weight="700" font-size="20" fill="#D9A63A" letter-spacing="3">${n} / ${TOTAL}${n < TOTAL ? ' →' : ''}</text>
</svg>`;
}
// ballot box + blank envelope illustration for the cover
const urna = `<svg width="1080" height="1080" viewBox="0 0 1080 1080" xmlns="http://www.w3.org/2000/svg" style="position:absolute;inset:0">
<defs>
<linearGradient id="glass" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#fff" stop-opacity=".16"/><stop offset="1" stop-color="#fff" stop-opacity=".04"/></linearGradient>
<linearGradient id="env" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#FFFDF7"/><stop offset="1" stop-color="#EFE6D3"/></linearGradient>
<radialGradient id="halo"><stop offset="0" stop-color="#F2C64B" stop-opacity=".45"/><stop offset="1" stop-color="#F2C64B" stop-opacity="0"/></radialGradient>
<filter id="sh" x="-30%" y="-30%" width="160%" height="160%"><feDropShadow dx="0" dy="8" stdDeviation="10" flood-color="#000" flood-opacity=".5"/></filter>
</defs>
<g transform="translate(540,0) scale(0.9) translate(-540,0) translate(0,90)">
<circle cx="540" cy="640" r="300" fill="url(#halo)"/>
<g stroke="#F2C64B" stroke-width="2" opacity=".28">
${Array.from({ length: 28 }, (_, i) => { const a = i * Math.PI * 2 / 28, r0 = 210, r1 = i % 2 ? 300 : 360; return `<line x1="${540 + r0 * Math.cos(a)}" y1="${640 + r0 * Math.sin(a)}" x2="${540 + r1 * Math.cos(a)}" y2="${640 + r1 * Math.sin(a)}"/>`; }).join('')}
</g>
<!-- envelope entering slot -->
<g filter="url(#sh)" transform="rotate(-4 540 560)">
<rect x="440" y="455" width="200" height="140" rx="4" fill="url(#env)"/>
<path d="M440,459 L540,530 L640,459" fill="none" stroke="#C9B48A" stroke-width="3"/>
</g>
<!-- urn: top face -->
<path d="M330,600 L750,600 L810,650 L270,650 Z" fill="#FBF3E4" fill-opacity=".10" stroke="#F2C64B" stroke-width="4" stroke-linejoin="round"/>
<rect x="455" y="614" width="170" height="14" rx="7" fill="#220306" stroke="#F2C64B" stroke-width="3"/>
<!-- front -->
<rect x="270" y="650" width="540" height="270" fill="url(#glass)" stroke="#F2C64B" stroke-width="4"/>
<line x1="270" y1="690" x2="810" y2="690" stroke="#F2C64B" stroke-width="2" opacity=".7"/>
<!-- envelopes resting inside -->
<g opacity=".55">
<rect x="310" y="850" width="150" height="62" fill="#FBF3E4" transform="rotate(-6 385 881)"/>
<rect x="470" y="862" width="150" height="52" fill="#FBF3E4" transform="rotate(4 545 888)"/>
<rect x="620" y="846" width="150" height="66" fill="#FBF3E4" transform="rotate(-3 695 879)"/>
</g>
<path d="M300,700 L330,700 L300,900 Z" fill="#fff" opacity=".07"/>
</g>
</svg>`;
const slides = [
// 1 portada
`${frame(1)}${urna}
<div style="position:absolute;left:0;right:0;top:182px;text-align:center">
<div style="font-family:Cinzel;font-weight:700;font-size:30px;letter-spacing:10px;color:#D9A63A">ELECCIONES GENERALES · 29N</div>
<div style="font-family:Cinzel;font-weight:900;font-size:118px;line-height:1.02;color:#FBF3E4;margin-top:22px;text-shadow:0 4px 12px rgba(0,0,0,.5)">VOTO EN<br>BLANCO</div>
</div>
<div style="position:absolute;left:0;right:0;top:722px;text-align:center;font-family:Garamond;font-style:italic;font-size:42px;line-height:1.2;color:#F2C64B;text-shadow:0 2px 10px rgba(0,0,0,.6)">Ninguno nos representa.<br>Todavía.</div>`,
// 2
`${frame(2)}<div class="txt">
<div class="kick">LA POSTURA DEL PNH</div>
<h1>¿Por qué no pedimos el voto para nadie?</h1>
<p>Ningún partido de los que se presentan el 29N defiende la <b>Hispanidad</b> como proyecto. Ninguno pone en el centro la <b>unidad de nuestros pueblos</b>, la <b>fe</b> que los formó y un <b>destino común</b> para España y América.</p>
<p>No vamos a elegir el mal menor. Vamos a decirlo con claridad en las urnas.</p>
</div>`,
// 3
`${frame(3)}<div class="txt">
<div class="kick">CÓMO SE VOTA EN BLANCO</div>
<h1>Blanco no es nulo.<br>Nulo no es blanco.</h1>
<div class="rows">
<div class="row hl"><div class="k">EN BLANCO</div><div class="v"><b style="color:#F2C64B">Congreso:</b> sobre vacío, sin papeleta. <b style="color:#F2C64B">Senado:</b> papeleta sin ninguna cruz. Es un voto válido y sale en los resultados oficiales.</div></div>
<div class="row"><div class="k">NULO</div><div class="v">Papeleta tachada, rota, con dibujos o dos papeletas distintas. No cuenta como voto válido.</div></div>
<div class="row"><div class="k">ABSTENCIÓN</div><div class="v">Quedarse en casa. No cuenta para nada.</div></div>
</div>
</div>`,
// 4
`${frame(4)}<div class="txt">
<div class="kick">¿Y POR QUÉ NO QUEDARSE EN CASA?</div>
<h1>Quien se abstiene, calla. Quien vota en blanco, habla.</h1>
<p>La abstención se lee como desinterés. Se mezcla con quien olvidó votar, con quien estaba de viaje y con quien no le importa nada.</p>
<div class="quote">El voto en blanco dice otra cosa: he venido, creo en mi Patria y ninguno de vosotros la merece.</div>
</div>`,
// 5
`${frame(5)}<div class="txt">
<div class="kick">HASTA QUE PODAMOS PRESENTARNOS</div>
<h1>La próxima vez, el PNH estará en la papeleta.</h1>
<p>El Partido Nacional Hispanista está en formación. Todavía no podemos concurrir a estas elecciones, pero estamos construyendo la alternativa.</p>
<p>Hasta entonces, <b>en blanco</b>. Y después, <b>con nosotros</b>.</p>
</div>`,
// 6 cierre
`${frame(6)}
<div style="position:absolute;left:0;right:0;top:200px;text-align:center">
<div style="font-family:Cinzel;font-weight:700;font-size:30px;letter-spacing:10px;color:#D9A63A">DOMINGO 29 DE NOVIEMBRE</div>
<div style="font-family:Cinzel;font-weight:900;font-size:104px;line-height:1.02;color:#FBF3E4;margin-top:20px;text-shadow:0 4px 12px rgba(0,0,0,.5)">VOTA EN<br>BLANCO</div>
</div>
<img src="data:image/png;base64,${logo}" style="position:absolute;left:355px;top:500px;width:370px;filter:drop-shadow(0 6px 10px rgba(0,0,0,.55))">
<div style="position:absolute;left:0;right:0;top:785px;text-align:center;font-family:Garamond;font-style:italic;font-size:40px;color:#F2C64B">Unidad, Fe y Destino</div>
<div style="position:absolute;left:0;right:0;top:860px;text-align:center;font-family:Cinzel;font-weight:700;font-size:30px;letter-spacing:5px;color:#FBF3E4">¡ARRIBA LA HISPANIDAD!</div>`,
];
const browser = await chromium.launch({ executablePath: '/opt/pw-browsers/chromium' });
const pg = await browser.newPage({ viewport: { width: 1080, height: 1080 }, deviceScaleFactor: 1 });
for (let i = 0; i < slides.length; i++) {
await pg.setContent(`<!doctype html><html><head><meta charset="utf-8"><style>${css}</style></head><body><div class="s">${slides[i]}</div></body></html>`);
await pg.evaluate(() => document.fonts.ready); await pg.waitForTimeout(150);
await pg.screenshot({ path: `${OUT}/votoenblanco_${i + 1}.png`, clip: { x: 0, y: 0, width: 1080, height: 1080 } });
}
await browser.close();
console.log('ok');