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

Rounded corners on rect Issue #849, absolute values on height and width #887

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dwcarr
Copy link

@dwcarr dwcarr commented Sep 7, 2022

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.

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 this pull request may close these issues.

None yet

1 participant