document.addEventListener('DOMContentLoaded', function() { // Initialize all feature cards document.querySelectorAll('feature-card').forEach(card => { feather.replace({ 'data-feather': card.shadowRoot.querySelector('[data-feather]') }); }); const inputText = document.getElementById('inputText'); const generateBtn = document.getElementById('generateBtn'); const downloadBtn = document.getElementById('downloadBtn'); const outputCanvas = document.getElementById('outputCanvas'); const showLines = document.getElementById('showLines'); const fontSizeInput = document.getElementById('fontSize'); const lineHeightInput = document.getElementById('lineHeight'); const letterSpacingInput = document.getElementById('letterSpacing'); // Initialize range inputs if (fontSizeInput) { fontSizeInput.addEventListener('input', updatePreview); } if (lineHeightInput) { lineHeightInput.addEventListener('input', updatePreview); } if (letterSpacingInput) { letterSpacingInput.addEventListener('input', updatePreview); } generateBtn.addEventListener('click', function() { const text = inputText.value.trim(); if (!text) { outputCanvas.innerHTML = '
Please enter some text first
'; return; } // Add loading state generateBtn.innerHTML = ' Generating...'; feather.replace(); // Simulate generation (in a real app, this would use a handwriting API) setTimeout(() => { const lines = text.split('\n'); let html = ''; if (showLines.checked) { html += '';
for (const line of lines) {
if (line.trim() === '') {
html += '
';
} else {
// Add slight variations to make it look more natural
const weightVariation = Math.random() * 0.4 - 0.2;
const sizeVariation = Math.random() * 0.4 - 0.2;
html += `${line}`;
}
html += '\n';
}
html += '