Skip to content

Instantly share code, notes, and snippets.

@miketahani
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketahani/73a5c2ae9026a8c0e9d2 to your computer and use it in GitHub Desktop.
Save miketahani/73a5c2ae9026a8c0e9d2 to your computer and use it in GitHub Desktop.
create a hovering image that displays the contents of an HTML5 canvas
(function () {
var img = document.createElement('img');
document.body.appendChild(img);
img.style.position = 'fixed';
img.style.top = 0;
img.style.right = 0;
img.style.width = '500px';
img.style.background = '#fff';
img.style['z-index'] = 1000000;
window.addEventListener('keypress', function (e) {
// "s" is for "snapshot"
if (e.keyCode === 115)
img.src = canvas.toDataURL();
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment