Badge artwork: 14 kie.ai renders (each its own shape and scene), name/earnings/tag stamped onto each piece's measured glass panel; tools/render-badges.mjs kept for reference

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-30 15:23:51 -05:00
parent 505f5cdae4
commit 37e92077c3
29 changed files with 9 additions and 4 deletions
+9 -4
View File
@@ -17,7 +17,10 @@ const CHAPTER_BADGES = { 1: 'ch1', 3: 'ch3', 5: 'ch5', 10: 'ch10', 15: 'ch15', 2
const REFUEL_BADGES = { 5: 'refuel5', 25: 'refuel25', 100: 'refuel100' };
let PUBLIC_DIR = null, CACHE_DIR = null;
function init(opts) { PUBLIC_DIR = opts.publicDir; CACHE_DIR = path.join(opts.dataDir, 'badges'); try { fs.mkdirSync(CACHE_DIR, { recursive: true }); } catch (e) {} }
const art = id => path.join(PUBLIC_DIR, 'badges', id + '.png');
const art = id => path.join(PUBLIC_DIR, 'badges', id + '.jpg');
// where each artwork's blank glass panel sits (fractions of height, measured on the kie.ai renders of 2026-09-30)
const PLATE = { ch1: [0.752, 0.949], ch3: [0.758, 0.949], ch5: [0.719, 0.946], ch10: [0.783, 0.95], ch15: [0.754, 0.93], ch20: [0.739, 0.949],
magnet: [0.758, 0.949], ship: [0.732, 0.949], shield: [0.754, 0.95], slow: [0.76, 0.945], refuel5: [0.76, 0.944], refuel25: [0.762, 0.949], refuel100: [0.76, 0.949], paid: [0.775, 0.961] };
function font(name) { const f = path.join(PUBLIC_DIR, 'fonts', name); if (fs.existsSync(f)) return f; for (const d of ['/usr/share/fonts/truetype/dejavu', '/usr/share/fonts/dejavu', '/usr/share/fonts/TTF']) { const g = path.join(d, 'DejaVuSans-Bold.ttf'); if (fs.existsSync(g)) return g; } return null; }
const ffText = t => String(t).replace(/\\/g, '\\\\').replace(/'/g, "\u2019").replace(/:/g, '\\:').replace(/%/g, '%%').replace(/,/g, '\\,');
// ffmpeg filter paths: forward slashes, drive colon escaped
@@ -31,9 +34,11 @@ function render(id, who, line2, tag) {
const name = String(who || '').slice(0, 24), sub = String(line2 || '').slice(0, 70), tg = String(tag || '').slice(0, 40);
const out = path.join(CACHE_DIR, id + '-' + crypto.createHash('sha1').update(name + '|' + sub + '|' + tg).digest('hex').slice(0, 12) + '.jpg');
if (fs.existsSync(out)) return resolve(out);
const vf = "drawtext=fontfile='" + ffPath(f1) + "':text='" + ffText(name) + "':fontcolor=#FFFFFF:fontsize=62:borderw=3:bordercolor=#22D3EE@0.9:shadowcolor=#000000@0.6:shadowx=0:shadowy=4:x=(w-text_w)/2:y=808"
+ ",drawtext=fontfile='" + ffPath(f2) + "':text='" + ffText(sub) + "':fontcolor=#FFC24B:fontsize=36:x=(w-text_w)/2:y=910"
+ (tg ? ",drawtext=fontfile='" + ffPath(f2) + "':text='" + ffText(tg) + "':fontcolor=#FF6A1A:fontsize=24:x=(w-text_w)/2:y=771" : ''); // Manrope: Orbitron has no middle dot
const H = 1080, pl = PLATE[id] || [0.76, 0.95], mid = (pl[0] + pl[1]) / 2 * H;
const nameY = Math.round(mid - (tg ? 44 : 52)), subY = Math.round(mid + (tg ? 26 : 18)), tagY = Math.round(pl[0] * H + 16);
const vf = "drawtext=fontfile='" + ffPath(f1) + "':text='" + ffText(name) + "':fontcolor=#FFFFFF:fontsize=58:borderw=3:bordercolor=#22D3EE@0.9:shadowcolor=#000000@0.7:shadowx=0:shadowy=4:x=(w-text_w)/2:y=" + nameY
+ ",drawtext=fontfile='" + ffPath(f2) + "':text='" + ffText(sub) + "':fontcolor=#FFE08A:fontsize=32:shadowcolor=#000000@0.7:shadowx=0:shadowy=2:x=(w-text_w)/2:y=" + subY
+ (tg ? ",drawtext=fontfile='" + ffPath(f2) + "':text='" + ffText(tg) + "':fontcolor=#FF8A48:fontsize=22:shadowcolor=#000000@0.7:shadowx=0:shadowy=2:x=(w-text_w)/2:y=" + tagY : ''); // Manrope: Orbitron has no middle dot
const p = spawn('ffmpeg', ['-v', 'error', '-y', '-i', art(id), '-vf', vf, '-frames:v', '1', '-q:v', '3', out], { stdio: ['ignore', 'ignore', 'pipe'] });
let err = ''; p.stderr.on('data', c => { err += c; });
p.on('error', () => resolve(null));
Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 411 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 408 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 467 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 433 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 436 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 458 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 460 KiB