var image = canvas.toDataURL();
var aDownloadLink = document.createElement('a'); // create a hidden link
aDownloadLink.download = 'canvas_image.png'; // add here the name of the file
aDownloadLink.href = image; // add the link href
aDownloadLink.click(); // click the link
var canvas =temp1
// Convert the canvas to data
var image = canvas.toDataURL();
// Create a link
var aDownloadLink = document.createElement('a');
// Add the name of the file to the link
aDownloadLink.download = 'canvas_image.png';
// Attach the data to the link
aDownloadLink.href = image;
// Get the code to click the download link
aDownloadLink.click();