// When the mouse is clicked...
$(canvas_element).mousedown(function(event) {
$(canvas_element).data('drawing', true);
var x = event.pageX - $(canvas_element).offset().left;
var y = event.pageY - $(canvas_element).offset().top;
// Grab the current coords
$(canvas_element).data('prev_x', x);
$(canvas_element).data('prev_y', y);
return false;
});
// When the mouse is moved...
$(canvas_element).mousemove(function(event) {
// Only do anything if we're drawing on the
// canvas at the moment.
if($(canvas_element).data('drawing'))