Fantasy Character Theme Song Creator
Generate a description for a theme song that fits your fantasy character.
Your fantasy character's theme song description will appear here!
Theme Song Description: ${themeSong.description}
${themeSong.lyrics ? `${themeSong.lyrics.replace(/\n/g, '
')}
` : ''}
`;
downloadBtn.style.display = 'block'; // Show download button
});
document.getElementById('clearBtn').addEventListener('click', () => {
document.getElementById('characterArchetype').value = 'any';
document.getElementById('personalityTrait').value = 'any';
document.getElementById('characterKeyword').value = '';
document.getElementById('includeLyrics').checked = false;
document.getElementById('themeSongResults').innerHTML = '')}
Your fantasy character\'s theme song description will appear here!
'; document.getElementById('downloadPdfBtn').style.display = 'none'; // Hide PDF button }); document.getElementById('downloadPdfBtn').addEventListener('click', () => { const resultsDiv = document.getElementById('themeSongResults'); const descriptionText = resultsDiv.querySelector('p strong') ? resultsDiv.querySelector('p').textContent.replace('Theme Song Description: ', '').trim() : ''; const lyricsHtml = resultsDiv.querySelector('.lyrics'); const lyricsText = lyricsHtml ? lyricsHtml.textContent.trim() : ''; if (!descriptionText || descriptionText === 'Your fantasy character\'s theme song description will appear here!') { alert("No theme song description to download."); return; } // --- PDF Generation --- const doc = new jsPDF(); const margin = 15; let y = margin; const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const maxLineWidth = pageWidth - 2 * margin; // Max width for text line doc.setFontSize(18); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 doc.text("Fantasy Character Theme Song", margin, y); y += 15; // Space after title doc.setFontSize(12); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 // Add Description doc.setFontSize(14); doc.text("Theme Song Description:", margin, y); y += 8; doc.setFontSize(12); const descriptionLines = doc.splitTextToSize(descriptionText, maxLineWidth); doc.text(descriptionLines, margin, y); y += (descriptionLines.length * 7) + 10; // Estimate space // Add Lyrics (if they exist) if (lyricsText) { // Add "Lyrical Themes:" title const lyricalThemesMatch = lyricsText.match(/Lyrical Themes:([^]+?)Sample Snippet:/); if (lyricalThemesMatch && lyricalThemesMatch[1]) { doc.setFontSize(14); doc.text("Lyrical Themes:", margin, y); y += 8; doc.setFontSize(12); const themesText = lyricalThemesMatch[1].trim(); const themesLines = doc.splitTextToSize(themesText, maxLineWidth); doc.text(themesLines, margin, y); y += (themesLines.length * 7) + 10; } else { // Fallback if title format changes doc.setFontSize(14); doc.text("Lyrical Content:", margin, y); y += 8; doc.setFontSize(12); } // Add "Sample Snippet:" title and lines const sampleSnippetMatch = lyricsText.match(/Sample Snippet:([^]+)/); if (sampleSnippetMatch && sampleSnippetMatch[1]) { doc.setFontSize(14); doc.text("Sample Snippet:", margin, y); y += 8; doc.setFontSize(12); const snippetContent = sampleSnippetMatch[1].trim(); const snippetLines = doc.splitTextToSize(snippetContent, maxLineWidth); snippetLines.forEach(line => { if (y + 7 > pageHeight - margin) { doc.addPage(); y = margin; doc.setFontSize(18); doc.setTextColor(52, 58, 64); doc.text("Fantasy Character Theme Song (cont.)", margin, y); y += 15; doc.setFontSize(14); doc.text("Sample Snippet (cont.):", margin, y); y += 8; doc.setFontSize(12); } doc.text(line, margin + 5, y); // Indent snippet lines slightly y += 7; }); } else if (lyricsText) { // If no specific format, just print raw lyrics text const rawLyricsLines = doc.splitTextToSize(lyricsText, maxLineWidth); rawLyricsLines.forEach(line => { if (y + 7 > pageHeight - margin) { doc.addPage(); y = margin; } doc.text(line, margin, y); y += 7; }); } } doc.save('character_theme_song.pdf'); });Benefits for End Users:
Personalization: Users can create a unique theme song tailored to their fantasy character.
Engagement: The interactive nature of the tool makes it fun and engaging.
Shareability: The PDF download feature allows users to share their character’s theme song with others.
Ease of Use: The tool is simple and intuitive, requiring no technical knowledge.
