-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
[Bugfix] qp_ellipse
overflow
#19005
[Bugfix] qp_ellipse
overflow
#19005
Conversation
Thank you for your contribution! |
Re-reading this many months later i feel like i should have just done |
There doesn't seem to be a copyright notice for the code in the linked site? Not sure we can accept it from a GPL perspective. |
Oh, right.. Didnt think about it back in the day. Just made minimal searching and found no info about its licensing, guess i will look for another impl that has a clear (and compatible) license and test with that. |
This draws much better than what i remember my first reimplementation doing. But I must say I'm not usually drawing ellipses... I dont have any metrics, but it definitely is slightly slower than the current code in the repo. I'm fine personally with the tradeoff, given the current code often draws very funny shapes, and this code is much simpler. |
qp_ellipse
For illustration on how it becomes very worse with size (crappy test code here) |
out of interest why rewrite it rather than just fixing the overflow? |
Just because i didnt know it was an overflow 🤣😅 |
qp_ellipse
qp_ellipse
overflow
Description
Not really sure if i should add the Bugfix and/or Core tags, so I'm not doing it.
Noticed that
qp_ellipse
does some weird drawing when somewhat-big inputs are provided. I saw this while testing my custom code to exposeQuantum Painter
overXAP
(there might be an issue on my part too 😅).To fix it, I've refactored the function using the mid-point ellipse algorithm, I haven't compared performance but I optimized the best that I could (nofloats
, reduced expressions, pre-compute values that are used all over the code).During tests I noticed that it draws significantly worse whensizey
is smaller thansizex
, so a check was added to flip values if needed and it draws pretty nice now.Note: The "tips" of the ellipse get trimmed as the sizes become bigger and the ratio between them is rather small: a cutoff line appears.Above text is now updated, ended up re-doing the algorithm from scratch based on the parametric equation for an ellipse, using lib8tion for the trigonometric functions.
Types of Changes
Issues Fixed or Closed by This PR
Checklist