Well, one of the first problems encountered is the need for a undo/redo functionality. Let's see a way to implement such thing.
Essentially when drawing we can imagine we pass through a series of different states. Each state represents the canvas aspect at that time. Clearly we have a continuous set of states, but it would be to "expensive" to consider and implement this way.
So we may consider a discrete set of states, where a new state is created consequentially to a user action (and not time dependent). Let's consider the creation of a new state consequent to a mousedown-mouseup action of the user, in other words a new state is created when the user draws something in one move.
Now imagine to consider three categories: past, present and future.
The present category includes only the present ...
read the full post