Initial Asset List
${appState.assets.length > 0 ? assetHtml : '
No assets defined yet.
'}
`;
document.getElementById('sdcd-document-preview').innerHTML = html;
}
// --- CHART JS ---
function initChart() {
const ctx = document.getElementById('sdcdRadarChart').getContext('2d');
chartInstance = new Chart(ctx, {
type: 'radar',
data: {
labels: ['Synthetic', 'Dense', 'Modern', 'Dark', 'Dynamic'],
datasets: [{
label: 'Aesthetic Target',
data: [30, 80, 60, 20, 90],
fill: true,
backgroundColor: 'rgba(233, 69, 96, 0.2)',
borderColor: 'rgba(233, 69, 96, 1)',
pointBackgroundColor: 'rgba(233, 69, 96, 1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(233, 69, 96, 1)'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
elements: { line: { borderWidth: 2 } },
scales: {
r: {
angleLines: { display: true, color: '#eee' },
suggestedMin: 0,
suggestedMax: 100,
ticks: { display: false } // Hide numbers for cleaner look
}
},
plugins: {
legend: { display: false }
}
}
});
}
function updateChart() {
if(!chartInstance) return;
const p = appState.profile;
const data = [p.synthetic, p.dense, p.modern, p.dark, p.dynamic];
chartInstance.data.datasets[0].data = data;
chartInstance.update();
}
// --- EXPORT ---
window.sdcd_generatePDF = function() {
const { jsPDF } = window.jspdf;
const element = document.getElementById('sdcd-document-preview');
// High quality capture
html2canvas(element, { scale: 2, useCORS: true }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF('p', 'mm', 'a4');
const imgWidth = 210; // A4 Width
const pageHeight = 297;
const imgHeight = canvas.height * imgWidth / canvas.width;
let heightLeft = imgHeight;
let position = 0;
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
// Handle overflow pages
while (heightLeft >= 0) {
position = heightLeft - imgHeight;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
heightLeft -= pageHeight;
}
const safeTitle = appState.meta.title.replace(/[^a-z0-9]/gi, '_').toLowerCase() || 'project';
pdf.save(`Sound_Design_Doc_${safeTitle}.pdf`);
});
};
// Start
init();
});