Created
February 13, 2020 15:10
-
-
Save jrc03c/040f7b606031d05697a22079e5d9e65b to your computer and use it in GitHub Desktop.
Download the contents of an HTML5 canvas as an image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function downloadCanvasAsImage(canvas, filename){ | |
let a = document.createElement("a") | |
a.href = canvas.toDataURL() | |
a.download = filename | |
a.dispatchEvent(new MouseEvent("click")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment