title: Finding if a point is on a line
body: <p>Let's say I have a line drawn as so in HTML5 Canvas:</p>
  
  <pre><code>...
  ctx.beginPath();
  ctx.moveTo(x,y);
  ctx.lineTo(x1,y1);
  ctx.closePath();
  ...
  </code></pre>
  
  <p>I want to find out if the mouse down event happened on this line, and I have code like this:</p>
  
  <pre><code>var handleMouseDown = function(e) {
    var coords = translateCoords(e.x,e.y);
    ...
    if (ctx.isPointInPath(coords.x, coords.y) {
      ...
  </code></pre>
  
  <p>Now, this code works fine in the case of circles &amp; rectangles, but not for lines. I have 2 questions:</p>
  
  <ol>
  <li><p>My thinking is that perhaps calling closePath() on a line itself is incorrect. Question - how can I check if the mouse down event happened on this line?</p></li>
  <li><p>How can I extend this to find if the mouse down event happened <em>near</em> the line?</p></li>
  </ol>