Presently, one has to right-click to download the image locally.
Let's maybe allow an image button to be added on hover that grabs the canvas content.
function downloadCanvas(canvas) {
// Get the canvas data as a data URL
var canvasDataUrl = canvas.toDataURL();
// Create a link element
var link = document.createElement('a');
link.href = canvasDataUrl;
link.download = 'downloaded_canvas.png'; // switch to code block?
// Append the link to the body
document.body.appendChild(link);
// Trigger a click event on the link
link.click();
// Remove the link from the body
document.body.removeChild(link);
}
Presently, one has to right-click to download the image locally.
Let's maybe allow an image button to be added on hover that grabs the canvas content.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL