fsm-designer/js/export/export-image.js

24 lines
533 B
JavaScript
Raw Normal View History

function exportToImage() {
if(activeDocument === null) {
return null;
}
return canvas.toDataURL('image/png');
}
function downloadImage(name, dataUrl) {
const element = document.createElement('a');
element.setAttribute('href', dataUrl);
element.setAttribute('download', name);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
function exportToImageFile() {
downloadImage('test.png', exportToImage());
}