Thursday, March 1, 2012

Basic of Canvas Element in HTML5



Solid Understanding of the Basics of Canvas Element in HTML5




HTML5 Canvas

Canvas element is useful for draw graphics on a web pages. With the help of canvas element we can draw rectangular area, and also control each and every pixels. It have various methods to draw any graphics.
Whenever we are going to draw any graphics first of all we should create Canvas element like:
< canvas id="CanvasID" width="100" height="100">< /canvas>
Canvas element have no drawing capability. So we must be done it in javaScript method like:



< script type="text/javascript">
var canId=document.getElementById("CanvasID");
var cantext= canId.getContext("2d");
cantext.fillStyle="#FF0000";
cantext.fillRect(0,0,180,95);
< /script>
Basically JavaScript uses id to find the canvas element:

No comments:

Post a Comment