oled icon indicating copy to clipboard operation
oled copied to clipboard

Fix & improve line drawing code

Open udoschneider opened this issue 2 years ago • 4 comments

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.

udoschneider avatar Jun 16 '22 22:06 udoschneider

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.

PhillippOhlandt avatar Jun 18 '22 11:06 PhillippOhlandt

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.

udoschneider avatar Jun 20 '22 23:06 udoschneider

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.

PhillippOhlandt avatar Jul 02 '22 16:07 PhillippOhlandt

Hey! The fix looks pretty good! Thank you @udoschneider. If you can fix the broken tests I agree to merge these changes.

luisgabrielroldan avatar Jul 11 '22 15:07 luisgabrielroldan