Enhance the rounded rectangle implementation#5597
Merged
simonbrunel merged 1 commit intochartjs:masterfrom Jun 26, 2018
Merged
Conversation
Use `arcTo` instead of `quadraticCurveTo` (both methods have the same compatibility level) because it generates better results when the final rect is a circle but also when it's actually a rectangle and not a square. This change is needed by the datalabels plugin where the user can configure the `borderRadius` and thus generate circle from a rounded rectangle.
simonbrunel
commented
Jun 26, 2018
| // NOTE(SB) `epsilon` helps to prevent minor artifacts appearing | ||
| // on Chrome when `r` is exactly half the height or the width. | ||
| var epsilon = 0.0000001; | ||
| var r = Math.min(radius, (height / 2) - epsilon, (width / 2) - epsilon); |
Member
Author
etimberg
approved these changes
Jun 26, 2018
benmccann
reviewed
Jun 26, 2018
| Math.SQRT2 * 2, | ||
| Math.SQRT2 * 2, | ||
| 2 / 2 | ||
| 2 * 0.425 |
Contributor
There was a problem hiding this comment.
maybe a comment here explaining what 0.425 is would be helpful
Member
Author
There was a problem hiding this comment.
2 / 2 wasn't explained, you need to read the roundedRect method to understand why and that's the same for 0.425, which one is properly explained in the method body. I don't think we should duplicate the comment here since it's exactly the same value in the calling code.
benmccann
approved these changes
Jun 26, 2018
exwm
pushed a commit
to exwm/Chart.js
that referenced
this pull request
Apr 30, 2021
Use `arcTo` instead of `quadraticCurveTo` (both methods have the same compatibility level) because it generates better results when the final rect is a circle but also when it's actually a rectangle and not a square. This change is needed by the datalabels plugin where the user can configure the `borderRadius` and thus generate circle from a rounded rectangle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Use
arcToinstead ofquadraticCurveTo(both methods have the same compatibility level) because it generates better results when the final rect is a circle but also when it's actually a rectangle and not a square. This change is needed by the datalabels plugin where the user can configure theborderRadiusand thus generate circle from a rounded rectangle.