 this.offsetTop) - rect.startY;
                ctx.clearRect(0, 0, canvas.width, canvas.height);
                drawRect();
            }
        }

        canvas.addEventListener('mousedown', mouseDown, false);
        canvas.addEventListener('mouseup', mouseUp, false);
        canvas.addEventListener('mousemove', mouseMove, false);

    </script>

</body>
</html>
