I have three arrys:
clickX = [],
clickY = [],
clickDrag = [];
this is what happens when you click down:
$(\'#canvasCur
Do not store painting to array
It slows down drawing critically. Just draw the latest line without clearing canvas. That way lineWeight changes does not affect to before drawings. So remove ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
and for
loop. You also might want to change context styles (lineWidth etc.) only when changes occur, not every time you run redraw()
function.
Undo support
Making different canvas for every mouse down session and drawing them together you can easily make undo feature. By pressing undo it simply splices latest canvas out of canvases array. Google to learn more about drawing to temporary canvas.