October 2016
Beginner to intermediate
709 pages
16h 52m
English
HTML5 brings a new element to web design, the <canvas> element. This is used to create graphics on a web page on the fly using JavaScript.
The <canvas> element creates a rectangular area on your page. It dimensions default to 300px by 150px. You can specify different settings inside the JavaScript. The code in this recipe grows quickly, so you can get the whole code online at the Packt Publishing's website.
To begin, create a simple HTML page with a <canvas> element:
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<canvas id="thecanvas"></canvas>
</body>
</html>The JavaScript gets the canvas element from the DOM.
var canvas = document.getElementById('thecanvas');It then calls the getContext() ...
Read now
Unlock full access