<html>
<head>
<style>
html, body {
padding: 0;
margin: 0;
}
canvas {
background-color: #eee;
}
</style>
</head>
<body>
<canvas></canvas>
<script>
var canvas = document.querySelector("canvas");
var ctx = canvas.getContext("2d");
canvas.addEventListener("mousemove", function (e) {
canvas.width = canvas.width;
ctx.strokeStyle = "red";
ctx.moveTo(0.5, canvas.height);
ctx.lineTo(e.pageX + 0.5, e.pageY + 0.5);
ctx.moveTo(canvas.width + 0.5, canvas.height + 0.5);
ctx.lineTo(e.pageX + 0.5, e.pageY + 0.5);
ctx.moveTo(canvas.width/2 + 0.5, 0.5);
ctx.lineTo(e.pageX + 0.5, e.pageY + 0.5);
ctx.stroke();
}, false);
</script>
</body>
</html>