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

Better circle drawing algorithm #7

Open
aviks opened this issue Aug 2, 2020 · 6 comments · May be fixed by #33
Open

Better circle drawing algorithm #7

aviks opened this issue Aug 2, 2020 · 6 comments · May be fixed by #33

Comments

@aviks
Copy link
Owner

aviks commented Aug 2, 2020

The current algorithm for drawing circles is not very good (though it is fast). It looks pretty ugly if the cirle is more than a about 10 pixels in diameter.

image

@aviks
Copy link
Owner Author

aviks commented Aug 2, 2020

Current implementation is here:

function draw(s::Screen, circle::Circle, c::Colorant=colorant"black"; fill=false)

@scottbigbrain
Copy link
Contributor

scottbigbrain commented Oct 4, 2020

I have been playing with making a better algorithm the last couple of days. Mine could use some more optimization, but as it is it isn't too much slower than the current one. It completely fills in the circle and so far shows no problems with being absurdly slow or not filling properly. When it only draws the circle outline it is sometimes thicker than necessary by a pixel in places, though it is only noticeable if you look close. My fork with the changes is here: https://github.com/potato-programming/GameZero.jl/blob/master/src/screen.jl

@aviks
Copy link
Owner Author

aviks commented Oct 4, 2020

Yeah, the current implementation is pretty poor, so anything else is probably an improvement. I'd be really happy to see a PR.

It'd be good to get a sense of how fast the new method is, using @time (run it more than once). It is not necessary for the new method to be be as fast as the old one to be accepted, but it shouldn't be, say 10x slower.

@scottbigbrain
Copy link
Contributor

I used @time, and one implementation was in fact 10x slower, but I managed to get it working quite a bit better. The current one seems to be about 2 - 3x slower, which isn't too bad.

@scottbigbrain
Copy link
Contributor

I have tested the algorithm as a custom function is a game program, but I have been unable to test it as a function that is inside the GameZero module because of issues with the current way that the game is run. I am going to try and install my version as a custom package to test it, I will send a PR when I have done all necessary testing.

@scottbigbrain
Copy link
Contributor

scottbigbrain commented Oct 18, 2020

There are still some bugs when fill=true with the new implementation. I mentioned this bug in the PR if anyone wants to take a swing at it.

Circle Draw PR

@albinahlback albinahlback linked a pull request Jan 14, 2021 that will close this issue
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 a pull request may close this issue.

2 participants