Rounded corners on rect Issue #849, absolute values on height and width #887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented rounded corners on rects with the addition of a corner_radius option attribute on the rect struct in rect.rs. If the corner_radius is None, this reduces to the same code as the base version.
Added the necessary boilerplate for mapping the corner_radius to the drawing attributes.
The approach for producing the rounded vertices used was similar to that employed in the ellipse primitive, where a SvgBuilder was implemented to construct the rectangle path.
In the course of this I found that the height and width properties on Dimensions were specified to be absolute values, but this was not being enforced, which led to unpredictable operation. (The example provided in draw.rs, link below, for instance, provides a negative value to the w function). I applied abs to each of these properties.
The draw.rs example was modified to demonstrate the new functionality, with the final rect demonstrating dynamic updates of the corner_radius, including setting radius to None (which produces results identical to the original behavior).
Project built and all examples ran successfully with 1.63.0 on Mac OS.
I am new to this library and to rust, so don't hesitate to give additional guidance.