Ability to have different radii for each corner of a rounded rectangle #7154
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.
Please do not update the README or Change Log, we will do this when we merge your PR.
This PR (delete as applicable)
Fixes a bugDescribe the changes below:
EDIT: This commit fixes the issue of jagged edges. This PR has been updated to match that logic. Since now this PR won't directly fix this issue, any mention of it will be crossed out below.
In summary, this PR adds the ability to set different radii for each corner of a rectangle,
and no longer reduces the amount of segments to render (fix #7152).I hope I followed all the rules for doing a pull request, please do let me know if I need to adjust anything. I'm especially not sure of how to properly handle the JSDoc comments.
All of the changes (to the Rectangle class, unless otherwise noted)
radiusTopLeft
,radiusTopRight
,radiusBottomLeft
andradiusBottomRight
have been added. These define the radii for their respective corners.isRounded
property has been changed to a getter. Returnstrue
if any of the new aforementioned radius properties are not equal to 0.setRounded
method are changed totopLeft
,topRight
,bottomLeft
andbottomRight
, for the ability to set the radius of each corner. If ONLYtopLeft
is defined, then that radius is applied to all 4 corners (this prevents existing use cases of this method from breaking).radius
property now acts as a getter and a setter. As a getter, it returnsradiusTopLeft
. As a setter, it runssetRounded
, passing in the value its being set to.updateRoundedData
has been adjusted to accommodate setting individual radii of each corner and edge.When calculating the segments, it no longer divides the radius by 5. This fixes an issue that was causing the corners to look rough in the WebGL renderer.DrawRoundedRect
function to support drawing individual radii for each corner.