Created
April 25, 2012 18:20
-
-
Save jviereck/2491890 to your computer and use it in GitHub Desktop.
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
<html> | |
<body> | |
<canvas id="canvas" style="border:1px solid black"></canvas> | |
<img id="image"></img> | |
<script> | |
var image = document.getElementById('image'); | |
var canvas = document.getElementById('canvas'); | |
var ctx = canvas.getContext('2d'); | |
ctx.fillStyle = "yellow"; | |
ctx.fillRect(0, 0, 300, 150); | |
ctx.fillStyle = "black"; | |
ctx.fillRect(50, 50, 200, 50); | |
// Load the current canvas content in the image. | |
image.src = canvas.toDataURL("image/jpeg", 1.0); | |
ctx.fillStyle = "white"; | |
ctx.fillRect(0, 0, 300, 150); | |
// Draw the image directly again. If the image is loaded, there should | |
// be something on the canvas :/ | |
ctx.drawImage(image, 10, 10); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment