-
Notifications
You must be signed in to change notification settings - Fork 163
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
Oval fix asymmetry #563
Oval fix asymmetry #563
Conversation
For comparison I also tried porting this algorithm from stackoverflow, but I couldn't get the fill quite right. Also it seems less optimized for performance, but has a slightly rounder look at some sizes. Edit: I pushed my unfinished work on this here if someone wants to play with it. |
Nice! I'm kinda wondering why some of the radii seem to give ovals more resembling octagons in the current solution. Comparing to the second one it's very clear. Is this something that could be fixed? |
Probably. I tried tweaking some of the parameters but wasn't able to improve it without messing up something else. Would take some work to fully understand the algorithm. I think it's partly because of this condition: wasm4/runtimes/web/src/framebuffer.ts Lines 211 to 212 in 868a6bb
If I remove || 2 * err > dy (which seems to prevent doubled pixels in the outline) it looks like this:![]() but then the vertical and horizontal ones are inconsistent in some cases.
It's a bit of a mixed bag. I agree the 16x16 circle looks better in algorithm 2, but 14x14 looks better in algorithm 1. |
I think the latest iteration looks great In the previous the circles have a round shape but the pixels are not drawn with a consistent symmetry ( We're splitting hairs (pixels) and the problem here is that there doesn't seem to be a "more correct" way of drawing pixellated circles. https://twitter.com/retronator/status/1029358469185462273/photo/1 In that tweet the top set has circles that are very close to real circles, while the others tend to become octagons... |
I agree that the top set in that tweet looks the best. In a reply the creator of a pixel art software apparently improved their algorithm to make better ellipses. |
Thank you everyone for looking into this. |
This seems like an improvement overall, feel free to iterate on it more if anything looks odd. Thanks! |
My little oval shadows and now rectangle shadows :( I guess I should just paint the shape I want though! |
Follow-up to #561.
I believe I figured out the discrepancy with drawOval compared to the TIC-80 version used as reference.
Their parameters are an inclusive bounding box. When calculating
![wasm4-screenshot-1](https://user-images.githubusercontent.com/1782216/189510692-4fdb1294-1d30-4932-a0f7-1ed4e500ed15.png)
a
andb
fromwidth
andheight
we need to subtract1
to match their algorithm. This seems to correct the asymmetry we were seeing at certain sizes:@desttinghim fyi