The colorpicker is actually a Canvas, with a background image of the color spectrum. To pick the color, get the background pixel color at a given point (x,y).
My implementation is pretty complex (in order to allow for implementation of other related features in the future), and also a kind of trade secret, so I will not share the exact details.
However, here is a basic look at how it is done:
Keep track of all Canvas drawing events.
To undo the last event, do the converse of the last event (for a line draw, that would mean drawing a line with paint color the same as background color).
But easier to implement. I saw a new drawing app pop up in the Community a couple days back that used this technique. I don’t know if it’s directly caused by the technique, but Undoing has white flashes when the Canvas fully reloads, in said app. In SketchPad there will be a slight delay for larger sketches, but no inconsistencies (or at least I hope so).
Maybe I should add this: The way I implemented Undo, it will enable some extra future features. It’s not limited to merely removing the last stroke.
I’m sorry but the extension I am using ended up not being publicly released, and the developer halted work on it. He very kindly gave me permission to use the testing version, but I can’t of course share it. I must say, just like you I am looking forward to a better built-in canvas without the jitters and precision issues.