Overview
In this blog, I am showing how you can easily provide animation in the images using an 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>