Comment
Comment by contravariant
Now hang on for a bit, I can vaguely understand what is going wrong with the ClearRect (though why it draws a line to the bottom right when the code just moves the pencil and draws a horizontal line is beyond me) but what on earth is with:
That's worse than a code smell, that reeks. Adding a new function to clear the state is nice, but what on earth is going on?