Development of a preview functionality with canvas
Do you remember the last post about canvas dealing with undo and redo functionality?
Now we'll see how to add a preview functionality, that is I want to see my straight line, or my circle, while keeping pressed the left mouse button and moving the pointer to change the shape size.
The first, bad, idea
Initially I thought that the way was to store the portion of canvas interested by the modification and restore it in the next mousemove call, so that the mousemove function has to respect the following flow:
- restore the previous saved state
- save the state of the portion of the canvas that now will be drawed
- draw the new state
Such flow works, but doesn ...