-
Notifications
You must be signed in to change notification settings - Fork 226
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
Expansion of the rounded buttons #401
Conversation
Looking good. Is this ready for merge? I see some commented out code. |
@djowel I added a small corner_radii struct, with initialization order: |
Hi @klytje I think the correct sequence is top_left, top_right, bottom_right, bottom_left :-) Interestingly, if you ask ChatGPT to make an API for drawing a round rectangle with customizable corner radii, it's the one it will recommend:
Then, I asked: "why did you specify the radii from top-left going clockwise?" ChatGPT follows the large language model from a vast source of programming code, and its answer is: "Specifying the radii from the top-left corner going clockwise is a common convention in graphics programming. It follows a logical order that aligns with how many people read and interpret shapes and diagrams." It is indeed customary in computer graphics to give precedence to the top-left, and in general, the horizontal coordinate first (i.e. x, before y). |
@djowel I implemented it according to the W3C docs: Indeed, looking at the my implementation you'll see the angle going from 0 --> 90 --> 180 --> 270 --> 360 as it is now: Your order is what I meant as the third option, following the |
Also I agree that starting from the top-left feels more natural for most objects, except circles :) |
BTW, skia goes so far as specify the horizontal and vertical radii for all corners: https://api.skia.org/classSkRRect.html But take note of the sequence:
|
Changed initialization order to |
Thanks for your patience! :-) |
Ouch. I forgot. This should be against skia_2024 first. Anyway, I'll just do the cherry-pick dance again. No worries. |
Oh gee... It seems Skia does arcs differently –not connecting the lines between the arcs! |
At least Quartz2D is doing it correctly! I'll push to a |
BTW, in the demo cpp, I think we should use grids to align the 3 R/G/B buttons properly. |
FYI: I have a fix for skia now. |
Ah cool! I gave it a quick glance this morning but realized I'd have to dedicate more time than I had to fix it :) |
OK fixed. I'll merge to skia_2024 |
Merged |
@klytje... Reopening, I think rounded_left is wrong: If you zoom in, the right-top and right-bottom corners are not sharp. It is fixed by using Or is it intentional? Assuming the default radius when not specified? It does not seem right, no? |
With this PR, we can now specify the 'roundedness' of each individual corner of a button.
There are now four ways to control them:
corner_radius(r)
method to specify all corners at once,corner_radius(r1, r2, r3, r4)
to specify them indivdually,rounded_*(r)
series of methods to specify a half-rounded side,rounded_corner_*(r)
series of methods to specify individual corners.I expanded the
Buttons
example to showcase this new functionality.I also added a missing implementation of the
gen_text_color text_color(color color_)
method I discovered during my testing. Previously it could not compile code specifying the text color of buttons.