Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (35 sloc) 1.15 KB
<!doctype html>
<meta charset="utf-8">
<title>Drawing App</title>
<link rel="stylesheet" href="../include/style.css">
Example from <a href=""><em>Foundation HTML5 Animation with JavaScript</em></a>
<canvas id="canvas" width="400" height="400"></canvas>
<aside>Click and draw with the mouse.</aside>
<script src="../include/utils.js"></script>
window.onload = function () {
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d'),
mouse = utils.captureMouse(canvas);
canvas.addEventListener('mousedown', function () {
context.moveTo(mouse.x, mouse.y);
canvas.addEventListener('mousemove', onMouseMove, false);
}, false);
canvas.addEventListener('mouseup', function () {
canvas.removeEventListener('mousemove', onMouseMove, false);
}, false);
function onMouseMove () {
context.lineTo(mouse.x, mouse.y);