Created
June 12, 2014 08:25
-
-
Save kkristof/45862b9662ed9f8e9fbc 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
<!DOCTYPE html> | |
<html> | |
<body> | |
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;"> | |
Your browser does not support the HTML5 canvas tag.</canvas> | |
<script> | |
var c=document.getElementById("myCanvas"); | |
var ctx=c.getContext("2d"); | |
ctx.fillStyle="red"; | |
ctx.fillRect(10,10,50,50); | |
ctx.fillStyle="blue"; | |
ctx.fillRect(20,20,50,50); | |
function copy() | |
{ | |
var imgData=ctx.getImageData(10,10,50,100); | |
ctx.putImageData(imgData,10,70, 30, 5, 20, 100); | |
} | |
</script> | |
<button onclick="copy()">Copy</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment