I need resize and redraw canvas, on mouse drawing.
I did demo, but this is not works, all time when i resize canvas it is clean all data
I tried different options like:
- temporary canvas
toDataURL
But without success
I need resize and redraw canvas, on mouse drawing.
I did demo, but this is not works, all time when i resize canvas it is clean all data
I tried different options like:
toDataURL
But without success
Your fiddle is working, i thing the only thing you missed is that resizing a canvas does clear it, so in the provided fiddle you clear it in fact on every single move of your mouse.
Edit : OK i think i understood your issues.
1) On resizing, you loose the content.
2) On resizing you loose current path, so you have to re-initiate a path drawing.
3) If you create a canvas on each mouse move, memory consumption will reach mountains and your app won't be reactive.
4) since the re-draw happens on a mouse move and not on a requestAnimationFrame, the whole thing will look quite hugly if you just do the full redraw on mouse move.
So i updated this fiddle so that it fixes all those issues :
try it here : http://jsfiddle.net/gamealchemist/JHr2P/78/
store / restore code :
updated mouse move code :