Fiction Worldbuilding Generator

Foundations of the Realm

The People and Their Society

The Nature of Power

World Genesis

The details of your new world will be chronicled here.

In this world, power stems from ${power.source}, specifically in the form of ${power.type.toLowerCase()}. This force is the key to both greatness and ruin.

`; placeholder.classList.add('hidden'); worldOutput.innerHTML = html; worldOutput.classList.remove('hidden'); outputActions.classList.remove('hidden'); }; const downloadPDF = async () => { const contentToPrint = document.getElementById('pdf-content'); if (!contentToPrint) return; if (typeof window.jspdf === 'undefined' || typeof window.html2canvas === 'undefined') { console.error("PDF generation library is not available."); return; } try { const { jsPDF } = window.jspdf; const pdfCanvas = await html2canvas(contentToPrint, { backgroundColor: '#111827', scale: 2 }); const imgData = pdfCanvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (pdfCanvas.height * pdfWidth) / pdfCanvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save('world-anvil.pdf'); } catch(err) { console.error("PDF generation failed:", err); } }; // --- Event Listeners --- nextBtn.addEventListener('click', () => navigate(1)); prevBtn.addEventListener('click', () => navigate(-1)); generateBtn.addEventListener('click', generateWorld); pdfBtn.addEventListener('click', downloadPDF); powerSourceSelect.addEventListener('change', (e) => { if (e.target.value === 'magic') { magicOptions.classList.remove('hidden'); techOptions.classList.add('hidden'); } else { magicOptions.classList.add('hidden'); techOptions.classList.remove('hidden'); } }); // --- Initial Setup --- updateTabs(); });
Scroll to Top