Html5 Canvas Tut (Image)

Overview

In this code blog am showing how you can easily provide animation in the images using HTML5 canvas tag.
you only have to call canvas element in your snippet using this tag:
<canvas id="myCanvas"> </canvas>

Code

<html>

<head>
   
<title>Canvas | Image</title>
   
<style>
        {

           
margin: 0px;
           
padding: 0px;
        }

   
</style>
</
head>
<
body>
   
<canvas id="myCanavs" width="320px" height="280px"></canvas>
   
<script>
       
var canvas = document.getElementById('mycanvas');
      
var context = canvas = canvas.getContext('2d');
       
var imageobj = new Image();
        imageobj.onload =
function () {
            context.drawimage(imageobj, 69, 50);

        };

        imageobj.source =
"12.jpg";
   
</script>
</
body>
</
html>
Ebook Download
View all
Learn
View all