Hello,
im pretty new to the whole html5-thing and I dont have any experience regarding JavaScript. Which is probably the reason why this wont work. I simply want to copy a part of a picture somewhere else in the canvas, but something seems to be wrong with my code.
I would really appreciate it if someone could take a look at my sourcecode.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function draw() {
var ctx = document.getElementById('cvs').getContext('2d');
var img = new Image();
img.src = 'futurama.png';
img.onload = function(){
ctx.drawImage(img,0,0);
}
var imgData = ctx.getImageData(50, 50, 80, 80);
ctx.putImageData(imgData, 400, 600);
}
</script>
</head>
<body onload="draw();">
<canvas id="cvs" width="600" height="1000">
</canvas>
</body>
</html>