Length of Chord Calculator

Length of Chord Calculator

Transparent

Inputs

Results

Chord Length

History

No calculations yet

`); printWindow.document.close(); printWindow.focus(); setTimeout(() => { printWindow.print(); printWindow.close(); }, 250); }function shareResults() { const name = document.getElementById('calculatorName').value || 'Chord Length Calculation'; const chordLength = document.getElementById('chordLength').textContent; const formula = document.getElementById('formulaText').textContent; const shareText = `${name}\n\nChord Length: ${chordLength}\n\nFormula: ${formula}\n\nCalculated with Length of Chord Calculator`; if (navigator.share) { navigator.share({ title: name, text: shareText }).catch(err => console.log('Error sharing:', err)); } else { // Fallback to clipboard copyToClipboard('chordLength'); alert('Results copied to clipboard!'); } }function exportToPNG() { // Create a canvas with the results const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); // Set canvas size canvas.width = 800; canvas.height = 600; // Background ctx.fillStyle = '#ffffff'; ctx.fillRect(0, 0, canvas.width, canvas.height); // Title ctx.fillStyle = '#333333'; ctx.font = 'bold 32px Arial'; ctx.textAlign = 'center'; ctx.fillText('Length of Chord Calculator', canvas.width / 2, 60); // Name const name = document.getElementById('calculatorName').value || 'Calculation Result'; ctx.font = '24px Arial'; ctx.fillText(name, canvas.width / 2, 100); // Date ctx.font = '16px Arial'; ctx.fillStyle = '#666666'; ctx.fillText(new Date().toLocaleString(), canvas.width / 2, 130); // Result box ctx.fillStyle = '#f8f9fa'; ctx.fillRect(50, 160, canvas.width - 100, 120); ctx.strokeStyle = '#e0e0e0'; ctx.strokeRect(50, 160, canvas.width - 100, 120); // Main result ctx.fillStyle = '#007cba'; ctx.font = 'bold 36px Arial'; ctx.textAlign = 'center'; ctx.fillText('Chord Length:', canvas.width / 2, 200); ctx.fillText(document.getElementById('chordLength').textContent, canvas.width / 2, 250); // Details ctx.fillStyle = '#333333'; ctx.font = '18px Arial'; ctx.textAlign = 'left'; ctx.fillText(`Radius Used: ${document.getElementById('radiusUsed').textContent}`, 80, 320); ctx.fillText(`Angle (Degrees): ${document.getElementById('angleDegrees').textContent}`, 80, 350); ctx.fillText(`Angle (Radians): ${document.getElementById('angleRadians').textContent}`, 80, 380); // Formula ctx.fillStyle = '#f1f3f4'; ctx.fillRect(50, 420, canvas.width - 100, 80); ctx.strokeStyle = '#007cba'; ctx.lineWidth = 4; ctx.strokeRect(50, 420, 4, 80); ctx.fillStyle = '#333333'; ctx.font = '16px Arial'; ctx.fillText('Formula Used:', 80, 445); ctx.font = '14px Courier New'; ctx.fillText(document.getElementById('formulaText').textContent, 80, 470); // Footer ctx.fillStyle = '#666666'; ctx.font = '12px Arial'; ctx.textAlign = 'center'; ctx.fillText('Generated by Length of Chord Calculator', canvas.width / 2, canvas.height - 20); // Download the image canvas.toBlob(blob => { const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `${name.replace(/[^a-z0-9]/gi, '_').toLowerCase()}_chord_calculation.png`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }); }