Villain Motivation Generator

Villain Motivation Generator

Craft compelling antagonists with layered motives and tragic flaws.

Villain Profile Dossier

${method.text}

Tragic Flaw

${flaw.text}

`; profileContent.innerHTML = generatedHtml; outputSection.classList.add('active'); // Store for PDF outputSection.dataset.motivation = motivation.text; outputSection.dataset.method = method.text; outputSection.dataset.flaw = flaw.text; }; // --- PDF Generation --- const downloadPdf = () => { if (typeof window.jspdf === 'undefined') { console.error('jsPDF library not loaded'); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const motivation = outputSection.dataset.motivation; const method = outputSection.dataset.method; const flaw = outputSection.dataset.flaw; const margin = 20, pageWidth = doc.internal.pageSize.getWidth(), usableWidth = pageWidth - margin * 2; let y = margin; // Dossier Header doc.setFont('Roboto Mono', 'bold'); doc.setFontSize(22); doc.setTextColor(40, 40, 40); doc.text("VILLAIN PROFILE DOSSIER", pageWidth / 2, y, { align: 'center' }); doc.setFontSize(10); doc.setTextColor(150); doc.text("CONFIDENTIAL // EYES ONLY", pageWidth / 2, y + 5, { align: 'center' }); y += 20; doc.setDrawColor(200, 200, 200); doc.setLineWidth(0.5); doc.line(margin, y, pageWidth - margin, y); y += 15; // Content Section const addSection = (title, content) => { doc.setFont('Roboto Mono', 'bold'); doc.setFontSize(11); doc.setTextColor(100, 100, 100); doc.text(title, margin, y); y += 7; doc.setFont('Inter', 'normal'); doc.setFontSize(12); doc.setTextColor(30, 30, 30); const textLines = doc.splitTextToSize(content, usableWidth); doc.text(textLines, margin, y); y += (textLines.length * 5) + 15; // Increased spacing }; addSection("CORE MOTIVATION:", motivation); addSection("PRIMARY METHOD:", method); addSection("TRAGIC FLAW:", flaw); // Footer const pageHeight = doc.internal.pageSize.getHeight(); doc.setFont('Roboto Mono', 'normal'); doc.setFontSize(9); doc.setTextColor(180); doc.text(`Generated: ${new Date().toLocaleDateString('en-US')}`, pageWidth / 2, pageHeight - 15, { align: 'center' }); doc.save('villain-motivation-profile.pdf'); }; // --- Event Listeners --- generateBtn.addEventListener('click', generateProfile); downloadPdfBtn.addEventListener('click', downloadPdf); });
Scroll to Top