Analysis: line tool

What I've thought would quick things to write often turn out to be the opposite. Writing the editor's line tool is a great example.

This wasn't particularly difficult, just difficult to get right. I'd finished this months ago and was only recently testing a different tool and noticed that it didn't paint the same as the original.

Original linet tool
Original's line tool

I was getting the direction from A->B and then traversing the line. It worked but too many cells were painted and it would produce different results if I dragged the line from B->A.

My attempt
Too many cells painted

Not only did it not match the original, the results were too unpredictable. After searching for line algorithms, I decided to give Bresenham's a go.

Bresenham's
Perfect match!

This new algorithm works a treat and is an exact match to the original.
The only difference is the way it highlights the path of the line. As you can see in the first image, knowing the cells that are going to be painted is impossible to see. I think this new pattern really helps when creating puzzles and avoids many undos. It also has a retro look to it and doesn't stand out in the wrong way.

Box
Same effect applied to the box tool