oled
oled copied to clipboard
Fix & improve line drawing code
Fixes #13, #14
Replace general coordinate sorting with specific sorting for line_h/line_v.
Replace generic x-based line drawing with standard Bresenham drawing which provides better results in all octants.
Hey, could you maybe provide some example images for the before and after? And is the new implementation faster, slower or equal?
EDIT: There are some before/after examples in the failed tests and I don't really like the look of the new implementation. Take a look at the X example. The new version looks broken.
I tried to make some visual comparisons here: https://github.com/udoschneider/oled_comparison
I'll check the X drawings ASAP.
However IMHO the bad quality of nearly vertical lines is typical for implementations which only use the x-Axis as a running variable to calculate the y position. You're basically ignoring the error buildup for y.
That's what Bresenham's Algorithm implemented in the "fix" takes care of.
Also after some thought I'm really not sure if any (more) drawing operations should be implemented in oled
at all. IMHO oled
provides the framebuffer. The task of (correctly) drawing are implemented by dedicated packages.
I think, in the end @luisgabrielroldan has to decide. Your comparison looks fine to me.
Also after some thought I'm really not sure if any (more) drawing operations should be implemented in oled at all. IMHO oled provides the framebuffer. The task of (correctly) drawing are implemented by dedicated packages.
The package provides enough primitives so that users can implement their own drawing. So I don't think we need to add new ones. But the existing ones should stay.
Hey! The fix looks pretty good! Thank you @udoschneider. If you can fix the broken tests I agree to merge these changes.