Skip to content

Instantly share code, notes, and snippets.

@aresnick
Created June 10, 2020 17:53
Show Gist options
  • Save aresnick/fd706272976c3cc8bf39289f9b9b37a8 to your computer and use it in GitHub Desktop.
Save aresnick/fd706272976c3cc8bf39289f9b9b37a8 to your computer and use it in GitHub Desktop.
var takeSnapshot = function() {
// A function to take a snapshot
var canvas = document.querySelector('canvas'); // Grab the canvas
var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); // Save the image
setTimeout(function() { window.location.href=image; }, 100); // Wait a bit to download the image; probably should use an event listener instead
}
// Regularly take a snapshot every 200ms
var timer = setInterval(takeSnapshot, 200)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment