18.11.2017 Views

html5_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12. HTML5 − Canvas<br />

HTML5<br />

HTML5 element gives you an easy and powerful way to draw graphics using<br />

JavaScript. It can be used to draw graphs, make photo compositions or do simple (and<br />

not so simple) animations.<br />

Here is a simple element which has only two specific<br />

attributes width and height plus all the core HTML5 attributes like id, name and class,<br />

etc.<br />

<br />

You can easily find that element in the DOM using getElementById() method as<br />

follows −<br />

var canvas = document.getElementById("mycanvas");<br />

Let us see a simple example on using element in HTML5 document.<br />

<br />

<br />

<br />

<br />

#mycanvas{border:1px solid red;}<br />

<br />

<br />

<br />

<br />

<br />

<br />

This will produce the following result –<br />

65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!