Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bresenham triangle filling #12

Closed
wants to merge 1 commit into from
Closed

Conversation

spearson78
Copy link
Contributor

Rather than trying to fix the existing algorithm I have migrated to a bresenham based triangle fill. This resolves all the weird rendering issues included the wide filled triangles at the 12:00 and 06:00 and makes the filled triangles identical to the non filled version.

I unfortunately had to make major changes to the line drawing to make it possible to draw 3 lines concurrently. I extracted the state of the line drawing to a struct to enable this. The triangle filling also requires that all lines are drawn in y++ direction so that we can step through each pixel this required significant changes to the logic.

These changes were much larger than I anticipated when I started down this path however the advantage of sharing the same line drawing algorithm seems worth it to me. so I thought I try a pull request.

If this isn't acceptable I can spend some more time working through the problems in the original algorithm.

@spearson78
Copy link
Contributor Author

I compared the original C code with the go code and finally tracked down the root cause.
The rendering of triangles is still a little strange (wide triangles at 12 and 6 o'clock and some dangling single pixels when rendering around 3 o'clock) these issues are however present in the original c code.

@spearson78
Copy link
Contributor Author

Simpler fix was merged.

@spearson78 spearson78 closed this Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant