draw image on canvas in html


<!DOCTYPE HTML>

<html>

<head>

<style>

body {

margin: 0px;

padding: 0px;

}

</style>

</head>

<body>

<div align=”center”>

<canvas id=”myCanvas” width=”578″ height=”400″></canvas>

</div>

<script>

var canvas = document.getElementById(‘myCanvas’);

var context = canvas.getContext(‘2d’);

var imageObj = new Image();

imageObj.onload = function() {

context.drawImage(imageObj, 69, 50);

};

imageObj.src = ‘url of the image’;

</script>

</body>

</html>

 

Leave a comment

Your email address will not be published. Required fields are marked *