Random Pirate Map Generator

Generate a description and basic visual for a fictional pirate treasure map!

Your random pirate map details will appear here!

Error: ${pirateMap.name}

${pirateMap.description}

// Display error message
${pirateMap.visual}
`; downloadBtn.style.display = 'none'; // Ensure button stays hidden on error } else { resultsDiv.innerHTML = `

Island Name: ${pirateMap.name}

Map Description: ${pirateMap.description}

Visual Preview:

${pirateMap.visual}
`; downloadPdfBtn.style.display = 'block'; // Show download button only on success } }); document.getElementById('clearBtn').addEventListener('click', () => { document.getElementById('islandShape').value = 'any'; document.getElementById('dominantTerrain').value = 'any'; document.getElementById('numTreasures').value = '1'; document.getElementById('dangerLevel').value = 'medium'; document.getElementById('mapComplexity').value = 'medium'; document.getElementById('mapKeyword').value = ''; document.getElementById('mapResults').innerHTML = '

Your random pirate map details will appear here!

'; document.getElementById('downloadPdfBtn').style.display = 'none'; // Hide PDF button }); // Download PDF Button document.getElementById('downloadPdfBtn').addEventListener('click', () => { const resultsDiv = document.getElementById('mapResults'); // Check if results are error message before attempting to get text if (resultsDiv.textContent.includes("Error:") || resultsDiv.textContent.includes('Your random pirate map details will appear here!')) { alert("No map details to download."); return; } const nameText = resultsDiv.querySelector('p:nth-child(1)') ? resultsDiv.querySelector('p:nth-child(1)').textContent.replace('Island Name: ', '').trim() : ''; const descriptionText = resultsDiv.querySelector('p:nth-child(2)') ? resultsDiv.querySelector('p:nth-child(2)').textContent.replace('Map Description: ', '').trim() : ''; const visualText = resultsDiv.querySelector('.map-visual') ? resultsDiv.querySelector('.map-visual').textContent : ''; if (!nameText) { // Should not happen if check passed, but for safety alert("No map details 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("Random Pirate Map", margin, y); y += 15; // Space after title doc.setFontSize(12); doc.setTextColor(52, 58, 64); // Match text-color variable #343a0 // Add Island Name doc.setFontSize(14); doc.text("Island Name:", margin, y); y += 8; doc.setFontSize(12); doc.text(doc.splitTextToSize(nameText, maxLineWidth), margin, y); y += (doc.splitTextToSize(nameText, maxLineWidth).length * 7) + 10; // Add Map Description doc.setFontSize(14); doc.text("Map Description:", margin, y); y += 8; doc.setFontSize(12); const descriptionLines = doc.splitTextToSize(descriptionText, maxLineWidth); doc.text(descriptionLines, margin, y); y += (descriptionLines.length * 7) + 10; // Add Visual Preview (using a monospace font) if (visualText.trim() !== "") { doc.setFontSize(14); doc.text("Visual Preview:", margin, y); y += 8; doc.setFont('courier', 'normal'); // Use monospace font for visual doc.setFontSize(8); // Smaller font for visual const visualLines = visualText.split('\n'); visualLines.forEach(line => { if (y + 5 > pageHeight - margin) { // Estimate line height for smaller font doc.addPage(); y = margin; doc.setFontSize(18); doc.setTextColor(52, 58, 64); doc.text("Random Pirate Map (cont.)", margin, y); y += 15; doc.setFontSize(14); doc.text("Visual Preview (cont.):", margin, y); y += 8; doc.setFont('courier', 'normal'); doc.setFontSize(8); } doc.text(line, margin, y); y += 5; // Estimate line height for smaller font }); doc.setFont('helvetica', 'normal'); // Reset font to default doc.setFontSize(12); // Reset font size y += 10; } doc.save('pirate_map_details.pdf'); });

Key Features

  1. Fictional Pirate Maps: Generates unique and imaginative pirate maps with island names, treasure locations, and mysterious clues.

  2. Header with Instructions: Includes a header with a title and brief instructions for ease of use.

  3. PDF Download: Allows users to download the generated map details as a PDF with a consistent color scheme.

  4. Centered Layout: The tool is perfectly centered on the page for a clean and professional look.

  5. Lightweight and Fast: Optimized for performance and works seamlessly in WordPress Elementor HTML blocks.

    Benefits for End Users

    1. Creative Exploration: Provides a fun and imaginative way to explore fictional pirate adventures.

    2. User-Friendly: Simple and intuitive interface ensures ease of use for all users.

    3. Portable Results: The PDF download feature allows users to save and share their findings effortlessly.

    4. Engaging Design: The tool’s modern design and consistent color scheme enhance the user experience.

    5. Privacy: No personal data is collected, ensuring complete privacy for users.

Scroll to Top