Simpler than the original version and v2 should draw faster. Still FTU
The first version created all the clones (used to record line coordinates and draw the line) when the project started so the "next" clone just needed to be "turned on" as you drew. But all the clones checked to see if they were the "next" one, so that caused lag. Instead, v2 just creates the clones as you draw.
Code that was in When is Pressed is now in When Object is Cloned. Also I simplified the setting of X2/Y2. An additional benefit of this method (v2) is that you're not limited to a preset number of lines (Clones). It'll just keep drawing until you hit the 4096 object limit (but it does get slower as more clones/lines are added).
It's a bit complicated, but FTU (maybe someone has a better method? But I couldn't find it)
The drawing pad itself is simplistic. Feel free to remix (or copy the code) and add all the features you prefer!
The basic premise of operation is that it records all the X & Y coordinates using a series of clones as you draw. Each clone has self properties for the starting & ending coordinates as well as a self property that tells each clone if it should draw it's lines during an Undo. When you press Undo (shake to undo, just like in Hopscotch) the entire image is redrawn except the last bit of the most recent line. You don't see the redraw because it happens all in one "step".
The only downside is you're limited to how much you can draw by how many clones there are. Also, the use of many clones currently makes the Hopscotch Player lag quite a bit, so I only used 600 clones. But you can change the Pen code to use more!
The idea here should theoretically also allow for layers & maybe even a zoom.
I'd enjoy any thoughts about how to do this differently
(Tap to enlarge)
Additional explanation below