Last active
August 29, 2015 14:16
-
-
Save miketahani/73a5c2ae9026a8c0e9d2 to your computer and use it in GitHub Desktop.
create a hovering image that displays the contents of an HTML5 canvas
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 () { | |
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