This version adds stroke events and makes canvas resizing more reliable:
beginStroke
endStroke
beforeUpdateStroke
afterUpdateStroke