Skip to content

Instantly share code, notes, and snippets.

@payne
Created March 10, 2014 19:55
Show Gist options
  • Save payne/9472962 to your computer and use it in GitHub Desktop.
Save payne/9472962 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<canvas width="300" height="300">
</canvas>
</body>
</html>
var c=document.querySelector('canvas');
var context=c.getContext('2d');
context.fillStyle='purple';
context.fillRect(0,0,300,300);
c.addEventListener('mousemove',
function(ev) {
console.log(ev.clientX);
context.fillStyle='yellow';
context.fillRect(ev.clientX,ev.clientY, 10,10);
},
false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment