Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upEnhance the rounded rectangle implementation #5597
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.
| // 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); |
This comment has been minimized.
This comment has been minimized.
| @@ -222,7 +222,7 @@ describe('Point element tests', function() { | |||
| 15 - offset, | |||
| Math.SQRT2 * 2, | |||
| Math.SQRT2 * 2, | |||
| 2 / 2 | |||
| 2 * 0.425 | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
simonbrunel
Jun 26, 2018
Author
Member
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.
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.

simonbrunel commentedJun 26, 2018
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.