x - 1, y - d3.event.dy - 1, 2, 2);
    var dx = xScale.invert(x) - xScale.invert(x - d3.event.dx);
    var dy = yScale.invert(y) - yScale.invert(y - d3.event.dy);
    userCoordinates.push([dx, dy, penState]);
    renderCoordinates(userCoordinates, inputCanvas);
    penState = 0;
  }

  function drawEnd() {
    x = d3.event.x;
    y = d3.event.y;
    var dx = xScale.invert(x) - xScale.invert(x - d3.event.dx);
    var dy = yScale.invert(y) - yScale.invert(y - d3.event.dy);
    userCoordinates.push([dx, dy, pe